<template>
	<AdminLayout activeKey="users" :breadcrumbs="['首页','用户管理','积分管理']" tabTitle="用户积分管理" currentPage="users-points">
		<view class="page">
			<!-- 页面头部 -->
			<view class="page-header">
				<view class="header-info">
					<text class="page-title">用户积分管理</text>
					<text class="page-subtitle">管理用户积分和信用分，查看明细记录</text>
					<view class="status-info">
						<text class="status-dot" :class="{ active: !loading }"></text>
						<text class="status-text">
							{{ loading ? '数据加载中...' : `最后更新: ${formatUpdateTime(lastUpdateTime)}` }}
						</text>
					</view>
				</view>
				<view class="header-actions">
					<view class="search-container">
						<view class="search-box">
							<text class="search-icon iconfont icon-sousuo"></text>
							<input class="search-input" 
								   v-model="searchKeyword" 
								   placeholder="搜索用户名或昵称..." 
								   @confirm="performSearch"
								   confirm-type="search" />
						</view>
						<button class="search-btn" @click="performSearch" :disabled="searching">
							<text class="btn-icon iconfont icon-sousuo"></text>
							<text>{{ searching ? '搜索中...' : '搜索' }}</text>
						</button>
						<button class="clear-btn" @click="clearSearch" v-if="isSearching">
							<text class="btn-icon iconfont icon-qingchu"></text>
							<text>清空</text>
						</button>
				</view>
				<button class="btn-secondary btn-compact" @click="showPointsRulesDialog">
					<text class="btn-icon iconfont icon-chakan"></text>
					查看积分规则
				</button>
				<button class="btn-primary btn-compact" @click="showBatchAdjustDialog">
					<text class="btn-icon iconfont icon-edit"></text>
					批量调整
				</button>
				</view>
			</view>
			
			<!-- 统计卡片 -->
			<view class="stats-cards">
				<view class="stat-card">
					<view class="stat-number">{{ totalUsers }}</view>
					<view class="stat-label">总用户数</view>
				</view>
				<view class="stat-card">
					<view class="stat-number">{{ avgPoints }}</view>
					<view class="stat-label">平均积分</view>
				</view>
				<view class="stat-card">
					<view class="stat-number">{{ avgCredit }}</view>
					<view class="stat-label">平均信用分</view>
				</view>
				<view class="stat-card">
					<view class="stat-number">{{ todayAdjustments }}</view>
					<view class="stat-label">今日调整次数</view>
				</view>
			</view>
			
		<!-- 用户积分列表 -->
		<view class="points-table-container">
			<view class="table-header">
				<view class="table-title">用户积分列表</view>
				
				<!-- 筛选和排序工具栏 -->
				<view class="filter-toolbar">
					<!-- 积分范围筛选 -->
					<view class="filter-group">
						<text class="filter-label">
							<text class="iconfont icon-jifen"></text> 积分范围
						</text>
						<view class="filter-range">
							<input 
								class="range-input" 
								type="number" 
								v-model="pointsRange.min" 
								placeholder="最小值" 
								@input="onMinPointsInput" />
							<text class="range-separator">-</text>
							<input 
								class="range-input" 
								type="number" 
								v-model="pointsRange.max" 
								placeholder="最大值" 
								@input="onMaxPointsInput" />
							<button class="apply-btn" @click="applyPointsFilter">应用</button>
							<button v-if="pointsFilter.min !== null || pointsFilter.max !== null" 
									class="clear-filter-btn" 
									@click="clearPointsFilter">
								<text class="iconfont icon-qingchu"></text>
							</button>
						</view>
					</view>
					
					<!-- 排序方式 -->
					<view class="filter-group">
						<text class="filter-label">
							<text class="iconfont icon-paixu"></text> 排序
						</text>
						<view class="sort-buttons">
							<button class="sort-btn" :class="{ active: sortBy === 'points_desc' }" @click="sortUsers('points_desc')">
								积分高→低
							</button>
							<button class="sort-btn" :class="{ active: sortBy === 'points_asc' }" @click="sortUsers('points_asc')">
								积分低→高
							</button>
							<button class="sort-btn" :class="{ active: sortBy === 'time_desc' }" @click="sortUsers('time_desc')">
								注册时间
							</button>
						</view>
					</view>
				</view>
				
				<view class="table-actions">
					<button class="btn-secondary" @click="loadUserPoints" :disabled="loading">
						<text class="btn-icon iconfont icon-shuaxin" :class="{ rotating: loading }"></text>
						{{ loading ? '刷新中...' : '手动刷新' }}
					</button>
				</view>
			</view>
				
				<view class="points-table">
					<view class="table-row table-header-row">
						<view class="table-cell cell-user">用户信息</view>
						<view class="table-cell cell-points">当前积分</view>
						<view class="table-cell cell-credit">信用分</view>
						<view class="table-cell cell-level">等级</view>
						<view class="table-cell cell-last-change">最近变动</view>
						<view class="table-cell cell-actions">操作</view>
					</view>
					
					<view class="table-row" v-for="user in filteredUsers" :key="user._id">
						<view class="table-cell cell-user">
							<view class="user-info">
								<view class="user-avatar">
									<text class="avatar-text">{{ getAvatarText(user.username) }}</text>
								</view>
								<view class="user-details">
									<view class="username">{{ user.username }}</view>
									<view class="nickname">{{ user.nickname || '未设置昵称' }}</view>
								</view>
							</view>
						</view>
						
						<view class="table-cell cell-points">
							<view class="points-info">
								<text class="points-value">{{ user.points || 0 }}</text>
								<text class="points-label">积分</text>
							</view>
						</view>
						
						<view class="table-cell cell-credit">
							<view class="credit-info">
								<text class="credit-value" :class="getCreditClass(user.credit_score)">
									{{ user.credit_score || 100 }}
								</text>
								<text class="credit-label">信用分</text>
							</view>
						</view>
						
						<view class="table-cell cell-level">
							<view class="level-badge" :class="getLevelClass(user.points)">
								{{ user.level_name || getUserLevel(user.points) }}
							</view>
						</view>
						
						<view class="table-cell cell-last-change">
							<view class="change-info" v-if="user.last_change">
								<text class="change-amount" :class="user.last_change.amount > 0 ? 'positive' : 'negative'">
									{{ user.last_change.amount > 0 ? '+' : '' }}{{ user.last_change.amount }}
								</text>
								<text class="change-reason">{{ user.last_change.reason }}</text>
								<text class="change-time">{{ formatDateShort(user.last_change.time) }}</text>
							</view>
							<text v-else class="no-change">暂无记录</text>
						</view>
						
						<view class="table-cell cell-actions">
							<view class="action-buttons">
								<button class="action-btn btn-detail" @click="viewUserDetail(user)" title="查看总览">
									<text class="btn-icon iconfont icon-chakan"></text>
								</button>
								<button class="action-btn btn-adjust" @click="showAdjustDialog(user)" title="调整分值">
									<text class="btn-icon iconfont icon-edit"></text>
								</button>
								<button class="action-btn btn-history" @click="viewHistory(user)" title="查看明细">
									<text class="btn-icon iconfont icon-rizhiguanli"></text>
								</button>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 调整积分/信用分对话框 -->
			<view v-if="showAdjustModal" class="modal-overlay" @click="hideAdjustDialog">
				<view class="modal-container" @click.stop>
					<view class="modal-header">
						<view class="modal-title">
							<text class="title-text">调整用户积分/信用分</text>
						</view>
						<button class="modal-close" @click="hideAdjustDialog">
							<text class="iconfont icon-guanbi"></text>
						</button>
					</view>
					
					<view class="modal-body">
						<!-- 用户信息卡片 -->
						<view class="user-info-card enhanced">
							<view class="user-avatar-wrapper">
								<view class="user-avatar">
									<text class="avatar-text">{{ getAvatarText(currentUser?.username) }}</text>
								</view>
								<view class="user-level-badge" :class="getLevelClass(currentUser?.level_name)">
									{{ currentUser?.level_name || '新手' }}
								</view>
							</view>
							<view class="user-details">
								<view class="username-row">
									<text class="username">{{ currentUser?.username }}</text>
								</view>
								<view class="stats-row">
									<view class="stat-item points">
										<text class="stat-icon iconfont icon-xinzeng"></text>
										<text class="stat-value">{{ currentUser?.points || 0 }}</text>
										<text class="stat-label">积分</text>
									</view>
									<view class="stat-divider"></view>
									<view class="stat-item credit">
										<text class="stat-icon iconfont icon-shenhe"></text>
										<text class="stat-value">{{ currentUser?.credit_score || 100 }}</text>
										<text class="stat-label">信用分</text>
									</view>
								</view>
							</view>
						</view>
						
						<!-- 调整表单 -->
						<view class="adjust-form enhanced">
							<!-- 类型切换标签 -->
							<view class="form-tabs modern">
								<button class="tab-btn modern" :class="{ active: adjustType === 'points' }" @click="adjustType = 'points'">
									<text class="tab-icon iconfont icon-xinzeng"></text>
									<text class="tab-text">积分调整</text>
								</button>
								<button class="tab-btn modern" :class="{ active: adjustType === 'credit' }" @click="adjustType = 'credit'">
									<text class="tab-icon iconfont icon-shenhe"></text>
									<text class="tab-text">信用分调整</text>
								</button>
							</view>
							
							<view class="form-content enhanced">
								<!-- 调整类型选择 -->
								<view class="form-group">
									<text class="form-label">
										<text class="label-icon iconfont icon-edit"></text>
										调整类型
									</text>
									<view class="action-buttons">
										<button class="action-btn" :class="{ active: adjustAction === 'add' }" @click="adjustAction = 'add'">
											<text class="action-icon iconfont icon-xinzeng"></text>
											<text class="action-text">增加</text>
										</button>
										<button class="action-btn" :class="{ active: adjustAction === 'subtract' }" @click="adjustAction = 'subtract'">
											<text class="action-icon iconfont icon-shanchu"></text>
											<text class="action-text">扣除</text>
										</button>
									</view>
								</view>
								
								<!-- 数量输入 -->
								<view class="form-group">
									<text class="form-label">
										<text class="label-icon iconfont icon-shujufenxi"></text>
										{{ adjustType === 'points' ? '积分' : '信用分' }}数量
									</text>
									<view class="amount-input-wrapper">
										<input class="form-input enhanced" type="number" v-model="adjustAmount" 
											   :placeholder="`请输入${adjustType === 'points' ? '积分' : '信用分'}数量`" />
										<view class="quick-amounts">
											<button class="quick-btn" @click="adjustAmount = '10'">+10</button>
											<button class="quick-btn" @click="adjustAmount = '50'">+50</button>
											<button class="quick-btn" @click="adjustAmount = '100'">+100</button>
										</view>
									</view>
								</view>
								
								<!-- 调整原因 -->
								<view class="form-group">
									<text class="form-label">
										<text class="label-icon iconfont icon-rizhiguanli"></text>
										调整原因
									</text>
									<view class="reason-tags enhanced">
										<button v-for="reason in reasonOptions" :key="reason" 
												class="reason-tag modern" :class="{ active: adjustReason === reason }"
												@click="adjustReason = reason">
											<text class="reason-icon iconfont" :class="getReasonIcon(reason)"></text>
											<text class="reason-text">{{ reason }}</text>
										</button>
									</view>
									<input class="form-input enhanced custom-reason-input" v-model="customReason" placeholder="自定义原因（可选）" />
								</view>
								
								<!-- 备注 -->
								<view class="form-group">
									<text class="form-label">
										<text class="label-icon iconfont icon-duanxin"></text>
										备注说明
									</text>
									<textarea class="form-textarea enhanced" v-model="adjustNote" 
											  placeholder="详细说明调整原因，便于后续查询和审计..."></textarea>
								</view>
								
								<!-- 预览效果 -->
								<view class="preview-section" v-if="adjustAmount">
									<text class="preview-title">
										<text class="iconfont icon-chakan"></text>
										调整预览
									</text>
									<view class="preview-content">
										<view class="preview-item">
											<text class="preview-label">调整前:</text>
											<text class="preview-value current">{{ adjustType === 'points' ? (currentUser?.points || 0) : (currentUser?.credit_score || 100) }}</text>
										</view>
										<text class="preview-arrow">→</text>
										<view class="preview-item">
											<text class="preview-label">调整后:</text>
											<text class="preview-value" :class="{ increase: adjustAction === 'add', decrease: adjustAction === 'subtract' }">
												{{ getPreviewValue() }}
											</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
					
					<view class="modal-footer">
						<button class="btn-cancel" @click="hideAdjustDialog">取消</button>
						<button class="btn-submit" @click="submitAdjustment" :disabled="submitting">
							<text v-if="submitting">处理中...</text>
							<text v-else>确认调整</text>
						</button>
					</view>
				</view>
			</view>

			<!-- 用户详情/历史记录对话框 -->
			<view v-if="showDetailModal" class="modal-overlay" @click="hideDetailDialog">
				<view class="modal-container large" @click.stop>
					<view class="modal-header">
						<view class="modal-title">
							<text class="title-icon iconfont icon-chakan"></text>
							<text class="title-text">{{ currentUser?.username }}积分详情</text>
						</view>
						<button class="modal-close" @click="hideDetailDialog">
							<text class="iconfont icon-guanbi"></text>
						</button>
					</view>
					
					<view class="modal-body">
						<view class="detail-tabs">
							<button class="tab-btn" :class="{ active: detailTab === 'overview' }" @click="detailTab = 'overview'">
								概览
							</button>
							<button class="tab-btn" :class="{ active: detailTab === 'points' }" @click="detailTab = 'points'">
								积分记录
							</button>
							<button class="tab-btn" :class="{ active: detailTab === 'credit' }" @click="detailTab = 'credit'">
								信用记录
							</button>
						</view>
						
						<view class="detail-content">
							<!-- 概览 -->
							<view v-if="detailTab === 'overview'" class="overview-content">
								<view class="stats-grid">
									<view class="stat-item">
										<text class="stat-value">{{ currentUser?.points || 0 }}</text>
										<text class="stat-label">当前积分</text>
									</view>
									<view class="stat-item">
										<text class="stat-value">{{ currentUser?.credit_score || 100 }}</text>
										<text class="stat-label">信用分</text>
									</view>
									<view class="stat-item">
										<text class="stat-value">{{ currentUser?.level_name || getUserLevel(currentUser?.points) }}</text>
										<text class="stat-label">用户等级</text>
									</view>
									<view class="stat-item">
										<text class="stat-value">{{ pointsHistory.length }}</text>
										<text class="stat-label">总记录数</text>
									</view>
								</view>
							</view>
							
					<!-- 积分记录 -->
					<view v-if="detailTab === 'points'" class="history-content">
						<!-- 筛选器 -->
						<view class="history-filter">
							<view class="filter-label">
								<text class="iconfont icon-shaixuan"></text>
								<text>类型筛选</text>
							</view>
							<view class="filter-buttons">
								<button class="filter-btn" :class="{ active: pointsHistoryFilter === 'all' }" @click="pointsHistoryFilter = 'all'">
									全部记录
								</button>
								<button class="filter-btn gain" :class="{ active: pointsHistoryFilter === 'gain' }" @click="pointsHistoryFilter = 'gain'">
									<text class="iconfont icon-xinzeng"></text> 获得
								</button>
								<button class="filter-btn consume" :class="{ active: pointsHistoryFilter === 'consume' }" @click="pointsHistoryFilter = 'consume'">
									<text class="iconfont icon-shanchu"></text> 消费
								</button>
							</view>
						</view>
							
							<!-- 时间线 -->
							<view class="timeline-container" v-if="filteredPointsHistory.length > 0">
								<view v-for="(record, index) in filteredPointsHistory" :key="record._id" class="timeline-item">
									<!-- 时间线节点 -->
									<view class="timeline-node" :class="record.amount > 0 ? 'node-gain' : 'node-consume'">
										<view class="node-dot"></view>
										<view class="node-line" v-if="index < filteredPointsHistory.length - 1"></view>
									</view>
									
									<!-- 记录卡片 -->
									<view class="timeline-card" :class="record.amount > 0 ? 'card-gain' : 'card-consume'">
										<view class="card-header">
											<view class="card-amount" :class="record.amount > 0 ? 'positive' : 'negative'">
												{{ record.amount > 0 ? '+' : '' }}{{ record.amount }}
												<text class="amount-unit">积分</text>
											</view>
											<view class="card-time">{{ formatDate(record.create_time) }}</view>
										</view>
										
										<view class="card-body">
											<view class="card-type">
												<text class="type-icon iconfont" :class="getRecordIcon(record)"></text>
												<text class="type-text">{{ getSmartScoreDescription(record) }}</text>
											</view>
											<view class="card-note" v-if="record.note">{{ record.note }}</view>
										</view>
										
										<view class="card-footer" v-if="record.operator">
											<text class="iconfont icon-user"></text>
											<text class="operator-text">{{ record.operator }}</text>
										</view>
									</view>
								</view>
							</view>
							
							<view v-else class="empty-state">
								<text class="iconfont icon-zanwushuju"></text>
								<text class="empty-text">暂无记录</text>
							</view>
						</view>
							
					<!-- 信用记录 -->
					<view v-if="detailTab === 'credit'" class="history-content">
						<!-- 筛选器 -->
						<view class="history-filter">
							<view class="filter-label">
								<text class="iconfont icon-shaixuan"></text>
								<text>类型筛选</text>
							</view>
							<view class="filter-buttons">
								<button class="filter-btn" :class="{ active: creditHistoryFilter === 'all' }" @click="creditHistoryFilter = 'all'">
									全部记录
								</button>
								<button class="filter-btn gain" :class="{ active: creditHistoryFilter === 'gain' }" @click="creditHistoryFilter = 'gain'">
									<text class="iconfont icon-xinzeng"></text> 增加
								</button>
								<button class="filter-btn consume" :class="{ active: creditHistoryFilter === 'consume' }" @click="creditHistoryFilter = 'consume'">
									<text class="iconfont icon-shanchu"></text> 扣除
								</button>
							</view>
						</view>
							
							<!-- 时间线 -->
							<view class="timeline-container" v-if="filteredCreditHistory.length > 0">
								<view v-for="(record, index) in filteredCreditHistory" :key="record._id" class="timeline-item">
									<!-- 时间线节点 -->
									<view class="timeline-node" :class="record.amount > 0 ? 'node-gain' : 'node-consume'">
										<view class="node-dot"></view>
										<view class="node-line" v-if="index < filteredCreditHistory.length - 1"></view>
									</view>
									
									<!-- 记录卡片 -->
									<view class="timeline-card" :class="record.amount > 0 ? 'card-gain' : 'card-consume'">
										<view class="card-header">
											<view class="card-amount" :class="record.amount > 0 ? 'positive' : 'negative'">
												{{ record.amount > 0 ? '+' : '' }}{{ record.amount }}
												<text class="amount-unit">信用分</text>
											</view>
											<view class="card-time">{{ formatDate(record.create_time) }}</view>
										</view>
										
										<view class="card-body">
											<view class="card-type">
												<text class="type-icon iconfont" :class="getRecordIcon(record)"></text>
												<text class="type-text">{{ getSmartScoreDescription(record) }}</text>
											</view>
											<view class="card-note" v-if="record.note">{{ record.note }}</view>
										</view>
										
										<view class="card-footer" v-if="record.operator">
											<text class="iconfont icon-user"></text>
											<text class="operator-text">{{ record.operator }}</text>
										</view>
									</view>
								</view>
							</view>
							
							<view v-else class="empty-state">
								<text class="iconfont icon-zanwushuju"></text>
								<text class="empty-text">暂无记录</text>
							</view>
						</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 调试积分计算对话框 -->
			<view v-if="showDebugModal" class="modal-overlay" @click="hideDebugModal">
				<view class="modal-container debug-modal" @click.stop>
					<view class="modal-header">
						<view class="modal-title">
							<text class="title-icon iconfont icon-shujufenxi"></text>
							<text class="title-text">调试积分计算系统</text>
						</view>
						<button class="modal-close" @click="hideDebugModal">
							<text class="iconfont icon-a-eyeclose-fill"></text>
						</button>
					</view>
					
					<view class="modal-body debug-body">
						<!-- 积分规则配置 -->
						<view class="debug-section">
							<view class="section-title">
								<text class="section-icon iconfont icon-setting-fill"></text>
								<text class="section-text">积分规则配置</text>
							</view>
							
							<view class="config-tabs">
								<button class="config-tab" :class="{ active: debugTab === 'posts' }" @click="debugTab = 'posts'">
									帖子积分
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'activities' }" @click="debugTab = 'activities'">
									活动积分
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'tasks' }" @click="debugTab = 'tasks'">
									任务积分
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'sign' }" @click="debugTab = 'sign'">
									签到积分
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'manual' }" @click="debugTab = 'manual'">
									手动调整
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'levels' }" @click="debugTab = 'levels'">
									等级设置
								</button>
								<button class="config-tab" :class="{ active: debugTab === 'system' }" @click="debugTab = 'system'">
									系统设置
								</button>
							</view>
							
							<view class="config-content">
								<!-- 帖子积分配置 -->
								<view v-if="debugTab === 'posts'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.postRewards" :key="key">
											<text class="config-label">{{ getPostLabel(key) }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updatePostReward(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
								</view>
								
								<!-- 活动积分配置 -->
								<view v-if="debugTab === 'activities'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.activityRewards" :key="key">
											<text class="config-label">{{ getActivityLabel(key) }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updateActivityReward(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
								</view>
								
								<!-- 任务积分配置 -->
								<view v-if="debugTab === 'tasks'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.taskRewards" :key="key">
											<text class="config-label">{{ getTaskLabel(key) }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updateTaskReward(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
								</view>
								
								<!-- 签到积分配置 -->
								<view v-if="debugTab === 'sign'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.signRewards" :key="key">
											<text class="config-label">{{ getSignLabel(key) }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updateSignReward(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
								</view>
								
								<!-- 手动调整配置 -->
								<view v-if="debugTab === 'manual'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.manualAdjust" :key="key">
											<text class="config-label">{{ getManualLabel(key) }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updateManualAdjust(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
									<view class="config-note">
										<text class="note-text">💡 手动调整可以设置正数或负数，用于管理员直接调整用户积分</text>
									</view>
								</view>
								
								<!-- 等级设置配置 -->
								<view v-if="debugTab === 'levels'" class="config-panel">
									<view class="config-grid">
										<view class="config-item" v-for="(value, key) in debugConfig.levelRequirements" :key="key">
											<text class="config-label">{{ key }}</text>
											<input class="config-input" type="number" :value="value" 
												   @input="updateLevelRequirement(key, $event.detail.value)" />
											<text class="config-unit">积分</text>
										</view>
									</view>
								</view>
								
								<!-- 系统设置配置 -->
								<view v-if="debugTab === 'system'" class="config-panel">
									<view class="config-grid">
										<view class="config-item">
											<text class="config-label">积分有效期</text>
											<input class="config-input" type="number" :value="debugConfig.pointsExpiry" 
												   @input="debugConfig.pointsExpiry = $event.detail.value" />
											<text class="config-unit">天</text>
										</view>
										<view class="config-item">
											<text class="config-label">每日积分上限</text>
											<input class="config-input" type="number" :value="debugConfig.dailyLimit" 
												   @input="debugConfig.dailyLimit = $event.detail.value" />
											<text class="config-unit">积分</text>
										</view>
										<view class="config-item">
											<text class="config-label">信用分影响系数</text>
											<input class="config-input" type="number" step="0.1" :value="debugConfig.creditMultiplier" 
												   @input="debugConfig.creditMultiplier = $event.detail.value" />
											<text class="config-unit">倍数</text>
										</view>
									</view>
								</view>
							</view>
						</view>
						
						<!-- 实时测试区域 -->
						<view class="debug-section">
							<view class="section-title">
								<text class="section-icon iconfont icon-xunjian"></text>
								<text class="section-text">实时测试</text>
							</view>
							
							<view class="test-controls">
								<view class="test-actions">
									<button class="test-btn" @click="runPointsTest">
										<text class="btn-icon iconfont icon-qiyong"></text>
										运行测试
									</button>
									<button class="test-btn secondary" @click="resetDebugConfig">
										<text class="btn-icon iconfont icon-shuaxin"></text>
										重置配置
									</button>
									<button class="test-btn secondary" @click="exportDebugConfig">
										<text class="btn-icon iconfont icon-gengduo"></text>
										导出配置
									</button>
								</view>
							</view>
							
							<view class="test-results" v-if="debugResults.length > 0">
								<view class="results-header">
									<text class="results-title">测试结果</text>
									<text class="results-count">{{ debugResults.length }} 条记录</text>
								</view>
								
								<view class="results-list">
									<view class="result-item" v-for="(result, index) in debugResults" :key="index">
										<view class="result-user">
											<text class="user-name">{{ result.username }}</text>
											<text class="user-info">当前: {{ result.before.points }}积分 / {{ result.before.creditScore }}信用分</text>
										</view>
										<view class="result-changes">
											<view class="change-item" v-for="change in result.changes" :key="change.action">
												<text class="change-action">{{ change.action }}</text>
												<text class="change-value" :class="change.points >= 0 ? 'positive' : 'negative'">
													{{ change.points >= 0 ? '+' : '' }}{{ change.points }}
												</text>
											</view>
										</view>
										<view class="result-final">
											<text class="final-points">最终: {{ result.after.points }}积分</text>
											<text class="final-level">等级: {{ result.after.level }}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
					
					<view class="modal-footer">
						<button class="btn-cancel" @click="hideDebugModal">关闭</button>
						<button class="btn-submit" @click="saveDebugConfig" :disabled="submitting">
							<text v-if="submitting">保存中...</text>
							<text v-else>保存配置</text>
						</button>
					</view>
				</view>
			</view>
			
			<!-- 积分规则查看对话框 -->
			<view v-if="showPointsRulesModal" class="modal-overlay" @click="hidePointsRulesDialog">
				<view class="modal-container rules-modal" @click.stop>
					<view class="modal-header">
						<view class="modal-title">
							<text class="title-icon iconfont icon-chakan"></text>
							<text class="title-text">积分规则说明</text>
						</view>
						<button class="modal-close" @click="hidePointsRulesDialog">
							<text class="iconfont icon-guanbi"></text>
						</button>
					</view>
					
					<view class="modal-body rules-body">
						<!-- 积分获取规则 -->
						<view class="rules-section">
							<view class="section-title">
								<text class="section-icon iconfont icon-xinzeng"></text>
								<text class="section-text">积分获取方式</text>
							</view>
							
							<view class="rules-list">
								<view class="rule-item">
									<view class="rule-header">
										<text class="rule-icon iconfont icon-duanxin"></text>
										<text class="rule-name">帖子相关</text>
									</view>
									<view class="rule-details">
										<view class="detail-row">
											<text class="detail-label">帖子置顶</text>
											<text class="detail-value">+{{ debugConfig.postRewards.post_pin }} 积分</text>
										</view>
										<view class="detail-row">
											<text class="detail-label">帖子获赞</text>
											<text class="detail-value">+{{ debugConfig.postRewards.post_like }} 积分</text>
										</view>
										<view class="detail-row">
											<text class="detail-label">评论获赞</text>
											<text class="detail-value">+{{ debugConfig.postRewards.comment_like }} 积分</text>
										</view>
									</view>
								</view>
								
								<view class="rule-item">
									<view class="rule-header">
										<text class="rule-icon iconfont icon-qiyong"></text>
										<text class="rule-name">活动相关</text>
									</view>
									<view class="rule-details">
										<view class="detail-row">
											<text class="detail-label">创建活动</text>
											<text class="detail-value">+{{ debugConfig.activityRewards.activity_create }} 积分</text>
										</view>
										<view class="detail-row">
											<text class="detail-label">参与活动</text>
											<text class="detail-value">+{{ debugConfig.activityRewards.activity_join }} 积分</text>
										</view>
									</view>
								</view>
								
								<view class="rule-item">
									<view class="rule-header">
										<text class="rule-icon iconfont icon-shenhe1"></text>
										<text class="rule-name">任务相关</text>
									</view>
									<view class="rule-details">
										<view class="detail-row">
											<text class="detail-label">完成任务</text>
											<text class="detail-value">+{{ debugConfig.taskRewards.task_finished }} 积分</text>
										</view>
										<view class="detail-row">
											<text class="detail-label">任务评价</text>
											<text class="detail-value">+{{ debugConfig.taskRewards.task_review }} 积分</text>
										</view>
									</view>
								</view>
								
								<view class="rule-item">
									<view class="rule-header">
										<text class="rule-icon iconfont icon-riqi"></text>
										<text class="rule-name">每日签到</text>
									</view>
									<view class="rule-details">
										<view class="detail-row">
											<text class="detail-label">每日签到</text>
											<text class="detail-value">+{{ debugConfig.signRewards.daily_sign }} 积分</text>
										</view>
									</view>
								</view>
							</view>
						</view>
						
						<!-- 用户等级 -->
						<view class="rules-section">
							<view class="section-title">
								<text class="section-icon iconfont icon-user"></text>
								<text class="section-text">用户等级体系</text>
							</view>
							
							<view class="levels-list">
								<view class="level-item" v-for="(points, levelName) in debugConfig.levelRequirements" :key="levelName">
									<view class="level-badge" :class="getLevelClassByName(levelName)">
										{{ levelName }}
									</view>
									<text class="level-requirement">{{ points }} 积分</text>
								</view>
							</view>
						</view>
						
						<!-- 其他说明 -->
						<view class="rules-section">
							<view class="section-title">
								<text class="section-icon iconfont icon-rizhiguanli"></text>
								<text class="section-text">其他说明</text>
							</view>
							
							<view class="info-list">
								<view class="info-item">
									<text class="info-icon">📅</text>
									<text class="info-text">积分有效期：{{ debugConfig.pointsExpiry }} 天</text>
								</view>
								<view class="info-item">
									<text class="info-icon">⚡</text>
									<text class="info-text">每日积分上限：{{ debugConfig.dailyLimit }} 积分</text>
								</view>
								<view class="info-item">
									<text class="info-icon">⭐</text>
									<text class="info-text">信用分影响系数：{{ debugConfig.creditMultiplier }}x</text>
								</view>
							</view>
						</view>
					</view>
					
					<view class="modal-footer">
						<button class="btn-cancel" @click="hidePointsRulesDialog">关闭</button>
					</view>
				</view>
			</view>
		</view>
	</AdminLayout>
</template>

<script>
import AdminLayout from '@/components/AdminLayout.vue'
export default {
	components: { AdminLayout },
	data() {
		return {
		keyword: '', // 保留原有的实时搜索关键词
		searchKeyword: '', // 搜索框输入的关键词
		userList: [], // 所有用户列表
		filteredUserList: [], // 搜索过滤后的用户列表
		pointsHistory: [],
		creditHistory: [],
		loading: false,
		searching: false, // 搜索状态
		isSearching: false, // 是否处于搜索模式
		pointsRange: {
			min: '',
			max: ''
		}, // 积分范围输入
		pointsFilter: {
			min: null,
			max: null
		}, // 应用的积分筛选
		sortBy: '', // 排序方式：'points_desc', 'points_asc', 'time_desc'
	showAdjustModal: false,
		showDetailModal: false,
		showDebugModal: false,
		showPointsRulesModal: false,
		currentUser: null,
			adjustType: 'points', // 'points' or 'credit'
			adjustAction: 'add', // 'add' or 'subtract'
			adjustAmount: '',
			adjustReason: '',
			customReason: '',
			adjustNote: '',
	submitting: false,
	detailTab: 'overview',
	debugTab: 'posts', // 调试弹窗的当前标签页
	pointsHistoryFilter: 'all', // 积分记录筛选：'all', 'gain', 'consume'
	creditHistoryFilter: 'all', // 信用分记录筛选：'all', 'gain', 'consume'
	reasonOptions: ['任务奖励', '活动奖励', '违规扣分', '系统调整', '客服补偿', '其他'],
			// 动态渲染相关
			refreshTimer: null,
			lastUpdateTime: 0,
			autoRefreshInterval: 30000, // 30秒自动刷新
			isPageVisible: true,
			
			// 调试积分计算相关
			debugConfig: {
				// 帖子相关积分规则
				postRewards: {
					post_pin: 20,         // 帖子置顶
					post_like: 2,         // 帖子获赞
					comment_like: 1       // 评论获赞
				},
				// 活动相关积分规则
				activityRewards: {
					activity_create: 50,  // 活动创建
					activity_join: 10     // 活动参与
				},
				// 任务相关积分规则
				taskRewards: {
					task_finished: 30,    // 任务完成
					task_review: 5        // 任务评价
				},
				// 签到积分规则
				signRewards: {
					daily_sign: 5         // 每日签到
				},
				// 手动调整规则
				manualAdjust: {
					manual_adjust: 0,     // 手动调整（可正可负）
					credit_adjust: 0      // 信用分调整（可正可负）
				},
				// 等级升级积分要求
				levelRequirements: {
					新手: 0,
					中级: 200,
					高级: 500,
					VIP: 1000,
					VIP白银: 2000,
					VIP黄金: 5000,
					VIP钻石: 10000
				},
				// 积分有效期（天）
				pointsExpiry: 365,
				// 每日积分上限
				dailyLimit: 100,
				// 信用分影响系数
				creditMultiplier: 1.0
			},
			
			// 调试测试数据
			debugTestUsers: [
				{ username: 'testUser1', currentPoints: 150, creditScore: 95 },
				{ username: 'testUser2', currentPoints: 800, creditScore: 88 },
				{ username: 'testUser3', currentPoints: 50, creditScore: 92 }
			],
			
			debugResults: []
		}
	},
	computed: {
		// 显示的用户列表：搜索模式下显示搜索结果，否则显示所有用户
		displayUsers() {
			return this.isSearching ? this.filteredUserList : this.userList;
		},
	// 实时搜索 + 积分筛选 + 排序
	filteredUsers() {
		let users = this.displayUsers;
		
		// 应用关键词搜索
		if (this.keyword) {
			users = users.filter(user => 
				this.safeStringIncludes(user.username, this.keyword) || 
				this.safeStringIncludes(user.nickname, this.keyword)
			);
		}
		
		// 应用积分范围筛选
		if (this.pointsFilter.min !== null || this.pointsFilter.max !== null) {
			users = users.filter(user => {
				const points = user.points || 0;
				const minValid = this.pointsFilter.min === null || points >= this.pointsFilter.min;
				const maxValid = this.pointsFilter.max === null || points <= this.pointsFilter.max;
				return minValid && maxValid;
			});
		}
		
		// 应用排序
		if (this.sortBy === 'points_desc') {
			users = [...users].sort((a, b) => (b.points || 0) - (a.points || 0));
		} else if (this.sortBy === 'points_asc') {
			users = [...users].sort((a, b) => (a.points || 0) - (b.points || 0));
		} else if (this.sortBy === 'time_desc') {
			users = [...users].sort((a, b) => (b.create_date || 0) - (a.create_date || 0));
		}
		
		return users;
	},
// 筛选后的积分历史记录
filteredPointsHistory() {
	if (this.pointsHistoryFilter === 'all') {
		return this.pointsHistory;
	} else if (this.pointsHistoryFilter === 'gain') {
		return this.pointsHistory.filter(record => record.amount > 0);
	} else if (this.pointsHistoryFilter === 'consume') {
		return this.pointsHistory.filter(record => record.amount < 0);
	}
	return this.pointsHistory;
},

// 筛选后的信用分历史记录
filteredCreditHistory() {
	if (this.creditHistoryFilter === 'all') {
		return this.creditHistory;
	} else if (this.creditHistoryFilter === 'gain') {
		return this.creditHistory.filter(record => record.amount > 0);
	} else if (this.creditHistoryFilter === 'consume') {
		return this.creditHistory.filter(record => record.amount < 0);
	}
	return this.creditHistory;
},
	
	totalUsers() {
		return this.displayUsers.length;
	},
	avgPoints() {
		if (!this.displayUsers.length) return 0;
		const total = this.displayUsers.reduce((sum, user) => sum + (user.points || 0), 0);
		return Math.round(total / this.displayUsers.length);
	},
		avgCredit() {
			if (!this.displayUsers.length) return 0;
			const total = this.displayUsers.reduce((sum, user) => sum + (user.credit_score || 100), 0);
			return Math.round(total / this.displayUsers.length);
		},
		todayAdjustments() {
			// 这里应该从后端获取今日调整次数
			return 12; // 示例数据
		}
	},
	onLoad() {
		console.log('页面加载，开始获取积分数据...');
		this.loadUserPoints();
		this.startAutoRefresh();
	},
	onShow() {
		console.log('页面显示，刷新积分数据...');
		this.isPageVisible = true;
		// 页面显示时刷新数据
		this.loadUserPoints();
		// 重新启动自动刷新
		this.startAutoRefresh();
	},
	onHide() {
		console.log('页面隐藏，停止自动刷新...');
		this.isPageVisible = false;
		this.stopAutoRefresh();
	},
	onUnload() {
		console.log('页面卸载，清理定时器...');
		this.stopAutoRefresh();
	},
	methods: {
		// 安全的字符串包含检查
		safeStringIncludes(str, searchTerm) {
			return str && typeof str === 'string' && str.toLowerCase().includes(searchTerm.toLowerCase());
		},
		
		// 执行搜索
		async performSearch() {
			if (!this.searchKeyword.trim()) {
				uni.showToast({ title: '请输入搜索关键词', icon: 'none' });
				return;
			}
			
			this.searching = true;
			
			try {
				console.log('执行搜索:', this.searchKeyword);
				
				// 在本地用户列表中搜索
				const keyword = this.searchKeyword.trim();
				const searchResults = this.userList.filter(user => 
					this.safeStringIncludes(user.username, keyword) || 
					this.safeStringIncludes(user.nickname, keyword)
				);
				
				this.filteredUserList = searchResults;
				this.isSearching = true;
				
				if (searchResults.length === 0) {
					uni.showToast({ title: '未找到匹配的用户', icon: 'none' });
				} else {
					uni.showToast({ title: `找到 ${searchResults.length} 个用户`, icon: 'success' });
				}
				
			} catch (e) {
				console.error('搜索失败:', e);
				uni.showToast({ title: '搜索失败', icon: 'none' });
			} finally {
				this.searching = false;
			}
		},
		
	// 清空搜索
	clearSearch() {
		this.searchKeyword = '';
		this.filteredUserList = [];
		this.isSearching = false;
		this.keyword = ''; // 同时清空实时搜索
		this.pointsRange.min = '';
		this.pointsRange.max = '';
		this.pointsFilter.min = null;
		this.pointsFilter.max = null;
		this.sortBy = '';
		uni.showToast({ title: '已清空搜索和筛选', icon: 'success' });
	},
	
	// 积分范围输入处理
	onMinPointsInput(event) {
		this.pointsRange.min = event.detail.value;
	},
	
	onMaxPointsInput(event) {
		this.pointsRange.max = event.detail.value;
	},
	
	// 应用积分筛选
	applyPointsFilter() {
		const min = this.pointsRange.min ? parseInt(this.pointsRange.min) : null;
		const max = this.pointsRange.max ? parseInt(this.pointsRange.max) : null;
		
		// 验证最小值不能大于最大值
		if (min !== null && max !== null && min > max) {
			uni.showToast({ title: '最小值不能大于最大值', icon: 'none' });
			return;
		}
		
		this.pointsFilter.min = min;
		this.pointsFilter.max = max;
		
		const minText = min !== null ? min : '不限';
		const maxText = max !== null ? max : '不限';
		uni.showToast({ title: `积分筛选: ${minText} - ${maxText}`, icon: 'success' });
	},
	
	// 清除积分筛选
	clearPointsFilter() {
		this.pointsRange.min = '';
		this.pointsRange.max = '';
		this.pointsFilter.min = null;
		this.pointsFilter.max = null;
		uni.showToast({ title: '已清除积分筛选', icon: 'success' });
	},
	
	// 排序用户
	sortUsers(sortType) {
		this.sortBy = sortType;
		const sortText = sortType === 'points_desc' ? '积分从高到低' : 
						sortType === 'points_asc' ? '积分从低到高' : '按注册时间';
		uni.showToast({ title: `排序: ${sortText}`, icon: 'success' });
	},
		
		async loadUserPoints(silent = false) {
			// silent为true时不显示loading，用于后台刷新
			if (!silent) {
				this.loading = true;
			}
			
			try {
				console.log('开始调用云函数获取用户积分...', silent ? '(静默刷新)' : '');
				// 调用云函数获取用户积分信息
				const res = await uniCloud.callFunction({
					name: 'userPointsManager',
					data: {
						action: 'getUserPoints'
					}
				});
				
				console.log('云函数返回结果:', res);
				
				if (res.result && res.result.code === 0) {
					console.log('云函数调用成功，获取到数据:', res.result.data);
					const newData = res.result.data || [];
					
					// 检查数据是否有变化
					const hasChanged = this.checkDataChanged(newData);
					
					this.userList = newData;
					this.lastUpdateTime = Date.now();
					
					if (hasChanged && silent) {
						console.log('检测到数据变化，更新界面');
						// 如果是静默刷新且数据有变化，可以显示提示
						uni.showToast({
							title: '数据已更新',
							icon: 'success',
							duration: 1500
						});
					}
					
					if (this.userList.length === 0 && !silent) {
						uni.showToast({ 
							title: '没有找到用户数据，请先初始化积分', 
							icon: 'none',
							duration: 3000
						});
					}
				} else {
					console.log('云函数返回错误:', res.result);
					if (!silent) {
						uni.showToast({ 
							title: res.result?.msg || '获取数据失败，使用模拟数据', 
							icon: 'none',
							duration: 2000
						});
						// 如果云函数不存在，使用模拟数据
						this.loadMockData();
					}
				}
			} catch (e) {
				console.error('获取用户积分失败:', e);
				if (!silent) {
					uni.showToast({ 
						title: '云函数调用失败: ' + (e.message || '未知错误'), 
						icon: 'none',
						duration: 3000
					});
					this.loadMockData();
				}
			} finally {
				if (!silent) {
					this.loading = false;
				}
			}
		},
		
		// 检查数据是否有变化
		checkDataChanged(newData) {
			if (this.userList.length !== newData.length) {
				return true;
			}
			
			for (let i = 0; i < newData.length; i++) {
				const oldUser = this.userList[i];
				const newUser = newData[i];
				
				if (!oldUser || 
					oldUser.points !== newUser.points ||
					oldUser.credit_score !== newUser.credit_score ||
					oldUser.level_name !== newUser.level_name ||
					JSON.stringify(oldUser.last_change) !== JSON.stringify(newUser.last_change)) {
					return true;
				}
			}
			
			return false;
		},
		
		// 启动自动刷新
		startAutoRefresh() {
			this.stopAutoRefresh(); // 先清除现有定时器
			
			if (this.autoRefreshInterval > 0) {
				console.log(`启动自动刷新，间隔: ${this.autoRefreshInterval/1000}秒`);
				this.refreshTimer = setInterval(() => {
					if (this.isPageVisible && !this.loading) {
						console.log('自动刷新积分数据...');
						this.loadUserPoints(true); // 静默刷新
					}
				}, this.autoRefreshInterval);
			}
		},
		
		// 停止自动刷新
		stopAutoRefresh() {
			if (this.refreshTimer) {
				console.log('停止自动刷新');
				clearInterval(this.refreshTimer);
				this.refreshTimer = null;
			}
		},
		
		loadMockData() {
			// 模拟数据
			this.userList = [
				{
					_id: '1',
					username: 'admin1112',
					nickname: '管理员2',
					points: 1250,
					total_points: 1500,
					used_points: 250,
					credit_score: 95,
					current_level: 4,
					level_name: 'VIP',
					continuous_days: 7,
					last_change: {
						amount: 50,
						reason: '任务奖励',
						description: '完成每日任务获得积分',
						time: Date.now() - 3600000
					}
				},
				{
					_id: '2',
					username: 'dahua',
					nickname: 'TaoJi',
					points: 800,
					total_points: 900,
					used_points: 100,
					credit_score: 88,
					current_level: 3,
					level_name: '高级',
					continuous_days: 3,
					last_change: {
						amount: -20,
						reason: '违规扣分',
						description: '发布不当内容被扣分',
						time: Date.now() - 86400000
					}
				},
				{
					_id: '3',
					username: 'zhang',
					nickname: 'nihao',
					points: 650,
					total_points: 700,
					used_points: 50,
					credit_score: 92,
					current_level: 3,
					level_name: '高级',
					continuous_days: 12,
					last_change: {
						amount: 30,
						reason: '活动奖励',
						description: '参与校园活动获得积分',
						time: Date.now() - 172800000
					}
				}
			];
		},
		
		showAdjustDialog(user) {
			this.currentUser = user;
			this.adjustType = 'points';
			this.adjustAction = 'add';
			this.adjustAmount = '';
			this.adjustReason = '系统调整';  // 设置默认原因
			this.customReason = '';
			this.adjustNote = '';
			this.showAdjustModal = true;
		},
		
		hideAdjustDialog() {
			this.showAdjustModal = false;
			this.currentUser = null;
		},
		
		async submitAdjustment() {
			if (!this.adjustAmount || this.adjustAmount <= 0) {
				uni.showToast({ title: '请输入有效的数量', icon: 'none' });
				return;
			}
			
			if (!this.adjustReason && !this.customReason) {
				uni.showToast({ title: '请选择或输入调整原因', icon: 'none' });
				return;
			}
			
			this.submitting = true;
			
			try {
				// 获取当前登录的管理员信息
				const userInfo = uni.getStorageSync('userInfo');
				const operator = userInfo ? (userInfo.nickname || userInfo.username || '管理员') : '系统管理员';
				
				// 验证和处理数量参数
				const amountValue = parseInt(this.adjustAmount);
				console.log('原始数量:', this.adjustAmount);
				console.log('解析后数量:', amountValue);
				console.log('数量是否有效:', !isNaN(amountValue) && amountValue > 0);
				
				const adjustData = {
					userId: this.currentUser._id,
					type: this.adjustType,
					adjustAction: this.adjustAction,  // 直接使用正确的参数名
					amount: amountValue,
					reason: this.customReason || this.adjustReason || '管理员调整',
					note: this.adjustNote || '',
					operator: operator
				};
				
				console.log('提交调整数据:', adjustData);
				console.log('当前用户信息:', this.currentUser);
				console.log('用户ID:', this.currentUser?._id);
				
				// 前端参数完整性检查
				const requiredParams = ['userId', 'type', 'adjustAction', 'amount', 'reason'];
				const missingParams = [];
				
				if (!adjustData.userId) missingParams.push('userId');
				if (!adjustData.type) missingParams.push('type');
				if (!adjustData.adjustAction) missingParams.push('adjustAction');
				if (!adjustData.amount || isNaN(adjustData.amount) || adjustData.amount <= 0) missingParams.push('amount');
				if (!adjustData.reason) missingParams.push('reason');
				
				if (missingParams.length > 0) {
					console.error('❌ 前端参数检查失败，缺少参数:', missingParams);
					uni.showToast({ 
						title: `参数错误：缺少 ${missingParams.join(', ')}`, 
						icon: 'none',
						duration: 3000
					});
					return;
				}
				
				// 调用云函数进行真实的数据库调整
				console.log(' 准备发送到云函数的完整数据:', {
					action: 'adjustUserPoints',
					userId: adjustData.userId,
					type: adjustData.type,
					adjustAction: adjustData.adjustAction,
					amount: adjustData.amount,
					reason: adjustData.reason,
					note: adjustData.note,
					operator: adjustData.operator
				});
				
				const res = await uniCloud.callFunction({
					name: 'userPointsManager',
					data: {
						action: 'adjustUserPoints',
						userId: adjustData.userId,
						type: adjustData.type,
						adjustAction: adjustData.adjustAction,
						amount: adjustData.amount,
						reason: adjustData.reason,
						note: adjustData.note,
						operator: adjustData.operator
					}
				});
				
				console.log('云函数调整结果:', res);
				
				if (res.result && res.result.code === 0) {
					const resultData = res.result.data;
					const typeText = adjustData.type === 'points' ? '积分' : '信用分';
					const actionText = adjustData.adjustAction === 'add' ? '增加' : '扣除';
					
					uni.showToast({ 
						title: `调整成功！${typeText}${actionText}${adjustData.amount}`, 
						icon: 'success',
						duration: 3000
					});
					
					// 显示调整详情到控制台
					console.log(`✅ 用户 ${this.currentUser.username} 的${typeText}从 ${resultData.oldValue} 调整为 ${resultData.newValue}`);
					
					this.hideAdjustDialog();
					// 立即刷新数据以显示最新结果
					this.loadUserPoints();
					
				} else {
					const errorMsg = res.result?.msg || '调整失败，请稍后重试';
					uni.showToast({ 
						title: errorMsg, 
						icon: 'none',
						duration: 3000
					});
					console.error('❌ 调整失败:', res.result);
				}
			} catch (e) {
				console.error('❌ 调整异常:', e);
				let errorMsg = '网络异常，请检查网络连接';
				
				if (e.message) {
					if (e.message.includes('uni-id')) {
						errorMsg = '用户身份验证失败';
					} else if (e.message.includes('database')) {
						errorMsg = '数据库操作失败';
					} else if (e.message.includes('function not found')) {
						errorMsg = '云函数未找到，请检查部署';
					} else {
						errorMsg = e.message;
					}
				}
				
				uni.showToast({ 
					title: errorMsg, 
					icon: 'none',
					duration: 3000
				});
			} finally {
				this.submitting = false;
			}
		},
		
		// 注意：模拟数据更新方法已移除，现在完全使用真实的数据库调整
		// 所有数据更新都通过云函数和数据库操作完成
		
		viewUserDetail(user) {
			this.currentUser = user;
			this.detailTab = 'overview';
			this.loadUserHistory(user._id);
			this.showDetailModal = true;
		},
		
		viewHistory(user) {
			this.currentUser = user;
			this.detailTab = 'points';
			this.loadUserHistory(user._id);
			this.showDetailModal = true;
		},
		
		hideDetailDialog() {
			this.showDetailModal = false;
			this.currentUser = null;
		},
		
		async loadUserHistory(userId) {
			try {
				// 调用云函数获取用户历史记录
				const res = await uniCloud.callFunction({
					name: 'userPointsManager',
					data: {
						action: 'getUserHistory',
						userId: userId
					}
				});
				
			if (res.result && res.result.code === 0) {
				// 调试：检查原始数据
				console.log('📦 原始积分历史数据（前3条）:');
				(res.result.pointsHistory || []).slice(0, 3).forEach((record, index) => {
					console.log(`${index + 1}. create_time:`, record.create_time, 
						'(类型:', typeof record.create_time, 
						') - ', record.note || record.reason);
				});
				
				// 获取数据并按时间排序（最新的在前）- 确保使用数值比较
				this.pointsHistory = (res.result.pointsHistory || []).sort((a, b) => {
					// 确保时间戳是数值类型
					const timeA = Number(a.create_time) || 0;
					const timeB = Number(b.create_time) || 0;
					return timeB - timeA; // 降序排序，最新的在前
				});
				
				this.creditHistory = (res.result.creditHistory || []).sort((a, b) => {
					const timeA = Number(a.create_time) || 0;
					const timeB = Number(b.create_time) || 0;
					return timeB - timeA;
				});
				
				// 调试：输出排序验证
				if (this.pointsHistory.length > 0) {
					console.log('✅ 积分历史记录排序后（前5条）:');
					this.pointsHistory.slice(0, 5).forEach((record, index) => {
						const timestamp = Number(record.create_time);
						const time = new Date(timestamp).toLocaleString('zh-CN');
						const desc = record.note || record.reason || '无描述';
						console.log(`${index + 1}. [${timestamp}] ${time} - ${desc} (${record.amount > 0 ? '+' : ''}${record.amount})`);
					});
				}
				} else {
					console.log('⚠️ 云函数返回错误，使用模拟数据:', res.result);
					// 模拟历史数据
					this.loadMockHistory();
				}
			} catch (e) {
				console.log('❌ 获取历史记录失败，使用模拟数据:', e);
				this.loadMockHistory();
			}
		},
		
		loadMockHistory() {
			// 创建模拟数据，时间严格按照最新到最旧排序
			const now = Date.now();
			const mockPointsData = [
				{
					_id: '2',
					amount: 2,
					type: 'post_like',
					reason: '帖子获赞',
					note: '用户发布的帖子获得点赞',
					create_time: now - 600000, // 10分钟前（最新）
					operator: '系统'
				},
				{
					_id: '1',
					amount: 20,
					type: 'post_pin',
					reason: '帖子置顶',
					note: '用户发布的帖子被管理员置顶',
					create_time: now - 3600000, // 1小时前
					operator: '系统'
				},
				{
					_id: '8',
					amount: 1,
					type: 'comment_like',
					reason: '评论获赞',
					note: '用户评论获得点赞',
					create_time: now - 7200000, // 2小时前
					operator: '系统'
				},
				{
					_id: '3',
					amount: 5,
					type: 'daily_sign',
					reason: '每日签到',
					note: '用户完成每日签到',
					create_time: now - 86400000, // 1天前
					operator: '系统'
				},
				{
					_id: '4',
					amount: 50,
					type: 'activity_create',
					reason: '创建活动',
					note: '用户创建校园活动',
					create_time: now - 172800000, // 2天前
					operator: '系统'
				},
				{
					_id: '5',
					amount: 10,
					type: 'manual_adjust',
					reason: '手动调整',
					note: '管理员手动调整用户积分',
					create_time: now - 259200000, // 3天前
					operator: '管理员A'
				},
				{
					_id: '7',
					amount: 30,
					type: 'task_finished',
					reason: '完成任务',
					note: '用户完成每日学习任务',
					create_time: now - 432000000, // 5天前
					operator: '系统'
				}
			];
			
			const mockCreditData = [
				{
					_id: '1',
					amount: -5,
					type: 'credit_adjust',
					reason: '信用分调整',
					note: '因违规行为扣除信用分',
					create_time: Date.now() - 86400000, // 1天前
					operator: '管理员A'
				},
				{
					_id: '2',
					amount: -2,
					type: 'credit_adjust',
					reason: '信用分调整',
					note: '因发布不当内容扣除信用分',
					create_time: Date.now() - 259200000, // 3天前
					operator: '管理员B'
				}
			];
			
		// 按时间排序（最新的在前）- 确保使用数值比较
		this.pointsHistory = mockPointsData.sort((a, b) => {
			const timeA = Number(a.create_time) || 0;
			const timeB = Number(b.create_time) || 0;
			return timeB - timeA; // 降序排序，最新的在前
		});
		
		this.creditHistory = mockCreditData.sort((a, b) => {
			const timeA = Number(a.create_time) || 0;
			const timeB = Number(b.create_time) || 0;
			return timeB - timeA;
		});
		
		// 输出最终排序结果
		console.log('🎯 模拟数据排序结果:');
		this.pointsHistory.slice(0, 5).forEach((record, index) => {
			const time = new Date(Number(record.create_time)).toLocaleString();
			console.log(`${index + 1}. ${time} - ${record.note} (${record.amount > 0 ? '+' : ''}${record.amount})`);
		});
		},
		
		async initUserPoints() {
			uni.showModal({
				title: '确认初始化',
				content: '这将为所有没有积分记录的用户创建默认积分数据（0积分），确定继续吗？',
				success: async (res) => {
					if (res.confirm) {
						uni.showLoading({ title: '初始化中...' });
						try {
							const result = await uniCloud.callFunction({
								name: 'userPointsManager',
								data: {
									action: 'initUserPoints'
								}
							});
							
							uni.hideLoading();
							
							if (result.result && result.result.code === 0) {
								uni.showToast({ 
									title: result.result.msg, 
									icon: 'success',
									duration: 3000
								});
								// 刷新数据
								this.loadUserPoints();
							} else {
								uni.showToast({ 
									title: result.result?.msg || '初始化失败', 
									icon: 'none' 
								});
							}
						} catch (e) {
							uni.hideLoading();
							console.error('初始化积分失败:', e);
							uni.showToast({ 
								title: '初始化失败，请稍后重试', 
								icon: 'none' 
							});
						}
					}
				}
			});
		},
		
		async debugDatabase() {
			uni.showLoading({ title: '检查中...' });
			try {
				const result = await uniCloud.callFunction({
					name: 'userPointsManager',
					data: {
						action: 'debugDatabase'
					}
				});
				
				uni.hideLoading();
				
				if (result.result && result.result.code === 0) {
					const data = result.result.data;
					const tableStatus = data.tables;
					
					let message = '数据库状态检查结果：\n\n';
					message += `用户表(uni-id-users): ${tableStatus['uni-id-users'].count}条记录 - ${tableStatus['uni-id-users'].status}\n`;
					message += `积分表(user_points): ${tableStatus['user_points'].count}条记录 - ${tableStatus['user_points'].status}\n`;
					message += `历史表(user-score): ${tableStatus['user-score'].count}条记录 - ${tableStatus['user-score'].status}\n\n`;
					
					if (tableStatus['user_points'].sample && tableStatus['user_points'].sample.length > 0) {
						message += '积分表样本数据：\n';
						tableStatus['user_points'].sample.forEach((sample, index) => {
							message += `${index + 1}. 积分:${sample.available_points}, 等级:${sample.level_name}\n`;
						});
					}
					
					uni.showModal({
						title: '数据库状态',
						content: message,
						showCancel: false
					});
				} else {
					uni.showToast({ title: result.result?.msg || '检查失败', icon: 'none' });
				}
			} catch (e) {
				uni.hideLoading();
				console.error('调试数据库失败:', e);
				uni.showToast({ title: '检查失败，请稍后重试', icon: 'none' });
			}
		},
		
		async resetUserPoints() {
			uni.showModal({
				title: '危险操作',
				content: '这将清空所有用户的积分记录并重新创建默认数据（0积分），此操作不可恢复！确定继续吗？',
				confirmColor: '#dc2626',
				success: async (res) => {
					if (res.confirm) {
						uni.showLoading({ title: '重置中...' });
						try {
							const result = await uniCloud.callFunction({
								name: 'userPointsManager',
								data: {
									action: 'resetUserPoints'
								}
							});
							
							uni.hideLoading();
							
							if (result.result && result.result.code === 0) {
								uni.showToast({ 
									title: result.result.msg, 
									icon: 'success',
									duration: 3000
								});
								// 刷新数据
								this.loadUserPoints();
							} else {
								uni.showToast({ 
									title: result.result?.msg || '重置失败', 
									icon: 'none' 
								});
							}
						} catch (e) {
							uni.hideLoading();
							console.error('重置积分失败:', e);
							uni.showToast({ 
								title: '重置失败，请稍后重试', 
								icon: 'none' 
							});
						}
					}
				}
			});
		},
		
	showBatchAdjustDialog() {
		uni.showToast({ title: '批量调整功能开发中', icon: 'none' });
	},
	
	// 显示积分规则弹窗
	showPointsRulesDialog() {
		this.showPointsRulesModal = true;
	},
	
	// 隐藏积分规则弹窗
	hidePointsRulesDialog() {
		this.showPointsRulesModal = false;
	},
	
	// 根据等级名称获取样式类
	getLevelClassByName(levelName) {
		const levelMap = {
			'新手': 'level-new',
			'中级': 'level-medium',
			'高级': 'level-high',
			'VIP': 'level-vip',
			'VIP白银': 'level-silver',
			'VIP黄金': 'level-gold',
			'VIP钻石': 'level-diamond'
		};
		return levelMap[levelName] || 'level-new';
	},
		
		// 调试积分计算
		async debugUserPoints() {
			console.log('打开调试积分计算弹窗');
			this.debugTab = 'posts';
			this.showDebugModal = true;
		},
		
		hideDebugModal() {
			this.showDebugModal = false;
			this.debugResults = [];
		},
		
		// 获取帖子标签
		getPostLabel(key) {
			const labels = {
				post_pin: '帖子置顶',
				post_like: '帖子获赞',
				comment_like: '评论获赞'
			};
			return labels[key] || key;
		},
		
		// 获取活动标签
		getActivityLabel(key) {
			const labels = {
				activity_create: '活动创建',
				activity_join: '活动参与'
			};
			return labels[key] || key;
		},
		
		// 获取任务标签
		getTaskLabel(key) {
			const labels = {
				task_finished: '任务完成',
				task_review: '任务评价'
			};
			return labels[key] || key;
		},
		
		// 获取签到标签
		getSignLabel(key) {
			const labels = {
				daily_sign: '每日签到'
			};
			return labels[key] || key;
		},
		
		// 获取手动调整标签
		getManualLabel(key) {
			const labels = {
				manual_adjust: '手动调整',
				credit_adjust: '信用分调整'
			};
			return labels[key] || key;
		},
		
		// 更新帖子奖励
		updatePostReward(key, value) {
			this.debugConfig.postRewards[key] = parseInt(value) || 0;
		},
		
		// 更新活动奖励
		updateActivityReward(key, value) {
			this.debugConfig.activityRewards[key] = parseInt(value) || 0;
		},
		
		// 更新任务奖励
		updateTaskReward(key, value) {
			this.debugConfig.taskRewards[key] = parseInt(value) || 0;
		},
		
		// 更新签到奖励
		updateSignReward(key, value) {
			this.debugConfig.signRewards[key] = parseInt(value) || 0;
		},
		
		// 更新手动调整
		updateManualAdjust(key, value) {
			this.debugConfig.manualAdjust[key] = parseInt(value) || 0;
		},
		
		// 更新等级要求
		updateLevelRequirement(key, value) {
			this.debugConfig.levelRequirements[key] = parseInt(value) || 0;
		},
		
		// 运行积分测试
		runPointsTest() {
			console.log('运行积分测试');
			this.debugResults = [];
			
			// 模拟测试各种积分计算场景
			const testScenarios = [
				{ action: '帖子置顶', type: 'post', key: 'post_pin' },
				{ action: '帖子获赞', type: 'post', key: 'post_like' },
				{ action: '评论获赞', type: 'post', key: 'comment_like' },
				{ action: '创建活动', type: 'activity', key: 'activity_create' },
				{ action: '参与活动', type: 'activity', key: 'activity_join' },
				{ action: '完成任务', type: 'task', key: 'task_finished' },
				{ action: '任务评价', type: 'task', key: 'task_review' },
				{ action: '每日签到', type: 'sign', key: 'daily_sign' }
			];
			
			this.debugTestUsers.forEach(user => {
				const result = {
					username: user.username,
					before: {
						points: user.currentPoints,
						creditScore: user.creditScore,
						level: this.getUserLevel(user.currentPoints)
					},
					changes: [],
					after: {
						points: user.currentPoints,
						creditScore: user.creditScore,
						level: ''
					}
				};
				
				// 随机选择1-3个测试场景
				const selectedScenarios = testScenarios.slice(0, Math.floor(Math.random() * 3) + 1);
				
				selectedScenarios.forEach(scenario => {
					let points = 0;
					
					switch(scenario.type) {
						case 'post':
							points = this.debugConfig.postRewards[scenario.key];
							break;
						case 'activity':
							points = this.debugConfig.activityRewards[scenario.key];
							break;
						case 'task':
							points = this.debugConfig.taskRewards[scenario.key];
							break;
						case 'sign':
							points = this.debugConfig.signRewards[scenario.key];
							break;
						case 'manual':
							points = this.debugConfig.manualAdjust[scenario.key];
							break;
					}
					
					// 应用信用分影响
					points = Math.floor(points * (user.creditScore / 100) * this.debugConfig.creditMultiplier);
					
					result.changes.push({
						action: scenario.action,
						points: points
					});
					
					result.after.points += points;
				});
				
				// 确保积分不为负
				result.after.points = Math.max(0, result.after.points);
				result.after.level = this.getUserLevel(result.after.points);
				
				this.debugResults.push(result);
			});
			
			uni.showToast({ 
				title: `测试完成，生成${this.debugResults.length}条结果`, 
				icon: 'success' 
			});
		},
		
		// 重置调试配置
		resetDebugConfig() {
			uni.showModal({
				title: '确认重置',
				content: '确定要重置所有积分规则配置吗？',
				success: (res) => {
					if (res.confirm) {
						this.debugConfig = {
							postRewards: {
								post_pin: 20,
								post_like: 2,
								comment_like: 1
							},
							activityRewards: {
								activity_create: 50,
								activity_join: 10
							},
							taskRewards: {
								task_finished: 30,
								task_review: 5
							},
							signRewards: {
								daily_sign: 5
							},
							manualAdjust: {
								manual_adjust: 0,
								credit_adjust: 0
							},
							levelRequirements: {
								新手: 0,
								中级: 200,
								高级: 500,
								VIP: 1000,
								VIP白银: 2000,
								VIP黄金: 5000,
								VIP钻石: 10000
							},
							pointsExpiry: 365,
							dailyLimit: 100,
							creditMultiplier: 1.0
						};
						
						uni.showToast({ title: '配置已重置', icon: 'success' });
					}
				}
			});
		},
		
		// 导出调试配置
		exportDebugConfig() {
			const configStr = JSON.stringify(this.debugConfig, null, 2);
			console.log('积分规则配置:', configStr);
			
			uni.showModal({
				title: '配置导出',
				content: '配置已输出到控制台，您可以复制保存',
				showCancel: false
			});
		},
		
		// 保存调试配置
		async saveDebugConfig() {
			this.submitting = true;
			
			try {
				// 这里可以调用云函数保存配置到数据库
				console.log('保存积分配置:', this.debugConfig);
				
				// 模拟保存过程
				await new Promise(resolve => setTimeout(resolve, 1000));
				
				uni.showToast({ title: '配置保存成功', icon: 'success' });
				this.hideDebugModal();
				
			} catch (e) {
				console.error('保存配置失败:', e);
				uni.showToast({ title: '保存失败', icon: 'none' });
			} finally {
				this.submitting = false;
			}
		},
		
		
		getUserLevel(points) {
			if (points >= 10000) return 'VIP钻石';
			if (points >= 5000) return 'VIP黄金';
			if (points >= 2000) return 'VIP白银';
			if (points >= 1000) return 'VIP';
			if (points >= 500) return '高级';
			if (points >= 200) return '中级';
			return '新手';
		},
		
		getLevelClass(points) {
			if (points >= 10000) return 'level-diamond';
			if (points >= 5000) return 'level-gold';
			if (points >= 2000) return 'level-silver';
			if (points >= 1000) return 'level-vip';
			if (points >= 500) return 'level-high';
			if (points >= 200) return 'level-medium';
			return 'level-new';
		},
		
		getCreditClass(score) {
			if (score >= 90) return 'credit-excellent';
			if (score >= 80) return 'credit-good';
			if (score >= 70) return 'credit-fair';
			return 'credit-poor';
		},
		
		formatDate(timestamp) {
			if (!timestamp) return '-';
			const date = new Date(timestamp);
			return date.toLocaleString('zh-CN');
		},
		
		formatDateShort(timestamp) {
			if (!timestamp) return '-';
			const date = new Date(timestamp);
			const now = new Date();
			
			// 获取日期的年月日，忽略时分秒
			const dateOnly = new Date(date.getFullYear(), date.getMonth(), date.getDate());
			const nowOnly = new Date(now.getFullYear(), now.getMonth(), now.getDate());
			
			const diffTime = nowOnly - dateOnly;
			const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
			
			
			if (diffDays === 0) return '今天';
			if (diffDays === 1) return '昨天';
			if (diffDays > 1 && diffDays < 7) return `${diffDays}天前`;
			if (diffDays < 0) return '未来'; // 处理异常情况
			return date.toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' });
		},
		
		getAvatarText(username) {
			if (!username) return '?';
			if (/[\u4e00-\u9fa5]/.test(username)) {
				return username.charAt(0);
			}
			return username.substring(0, 2).toUpperCase();
		},
		
		formatUpdateTime(timestamp) {
			if (!timestamp) return '未更新';
			const now = Date.now();
			const diff = now - timestamp;
			
			if (diff < 60000) { // 1分钟内
				return '刚刚';
			} else if (diff < 3600000) { // 1小时内
				return `${Math.floor(diff / 60000)}分钟前`;
			} else if (diff < 86400000) { // 24小时内
				return `${Math.floor(diff / 3600000)}小时前`;
			} else {
				return new Date(timestamp).toLocaleString('zh-CN');
			}
		},
		
		// 根据积分变动类型获取中文描述
		getScoreTypeDescription(type) {
			const typeMap = {
				'post_pin': '帖子置顶',
				'post_like': '帖子获赞',
				'comment_like': '评论获赞',
				'daily_sign': '每日签到',
				'activity_create': '创建活动',
				'activity_join': '参与活动',
				'task_finished': '完成任务',
				'task_review': '任务评价',
				'manual_adjust': '手动调整',
				'credit_adjust': '信用分调整'
			};
			return typeMap[type] || '系统调整';
		},
		
		// 智能推断积分变动描述
		getSmartScoreDescription(record) {
			// 如果有type字段，直接使用type转换
			if (record.type) {
				return this.getScoreTypeDescription(record.type);
			}
			
			// 如果没有type字段，但有description字段，尝试从description推断
			if (record.description) {
				const desc = record.description.toLowerCase();
				if (desc.includes('置顶') || desc.includes('pin')) return '帖子置顶';
				if (desc.includes('点赞') || desc.includes('like')) {
					if (desc.includes('评论')) return '评论获赞';
					return '帖子获赞';
				}
				if (desc.includes('签到') || desc.includes('sign')) return '每日签到';
				if (desc.includes('创建活动') || desc.includes('activity_create')) return '创建活动';
				if (desc.includes('参与活动') || desc.includes('activity_join')) return '参与活动';
				if (desc.includes('完成任务') || desc.includes('task_finished')) return '完成任务';
				if (desc.includes('任务评价') || desc.includes('task_review')) return '任务评价';
			}
			
			// 如果有reason字段，尝试从reason推断
			if (record.reason) {
				const reason = record.reason;
				if (reason.includes('置顶')) return '帖子置顶';
				if (reason.includes('获赞') || reason.includes('点赞')) {
					if (reason.includes('评论')) return '评论获赞';
					return '帖子获赞';
				}
				if (reason.includes('签到')) return '每日签到';
				if (reason.includes('创建活动')) return '创建活动';
				if (reason.includes('参与活动')) return '参与活动';
				if (reason.includes('完成任务')) return '完成任务';
				if (reason.includes('任务评价')) return '任务评价';
				if (reason.includes('手动调整')) return '手动调整';
				if (reason.includes('信用分')) return '信用分调整';
			}
			
			// 默认返回原reason或系统调整
			return record.reason || '系统调整';
		},
		
	// 获取调整原因对应的图标
	getReasonIcon(reason) {
		const iconMap = {
			'帖子置顶': 'icon-xinzeng',
			'帖子获赞': 'icon-shenhe',
			'评论获赞': 'icon-duanxin',
			'每日签到': 'icon-riqi',
			'创建活动': 'icon-qiyong',
			'参与活动': 'icon-user',
			'完成任务': 'icon-shenhe1',
			'任务评价': 'icon-shenhe',
			'手动调整': 'icon-setting-fill',
			'信用分调整': 'icon-edit',
			'任务奖励': 'icon-xinzeng',
			'活动奖励': 'icon-qiyong',
			'违规扣分': 'icon-jinzhi',
			'系统调整': 'icon-setting-fill',
			'客服补偿': 'icon-user',
			'其他': 'icon-rizhiguanli'
		};
		return iconMap[reason] || 'icon-rizhiguanli';
	},
	
	// 获取记录图标（用于时间线）
	getRecordIcon(record) {
		const description = this.getSmartScoreDescription(record);
		return this.getReasonIcon(description);
	},
		
		// 获取调整后的预览值
		getPreviewValue() {
			if (!this.adjustAmount || !this.currentUser) return 0;
			
			const current = this.adjustType === 'points' 
				? (this.currentUser.points || 0) 
				: (this.currentUser.credit_score || 100);
			
			const amount = parseInt(this.adjustAmount) || 0;
			
			if (this.adjustAction === 'add') {
				return current + amount;
			} else {
				return Math.max(0, current - amount); // 不能小于0
			}
		}
	}
}
</script>

<style scoped>
/* 页面主体 */
.page {
	padding: 32rpx;
	background: #f8fafc;
	min-height: 100vh;
}

/* 页面头部 */
.page-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 32rpx;
	padding: 0 8rpx;
}

.header-info .page-title {
	font-size: 48rpx;
	font-weight: 700;
	color: #1a202c;
	margin-bottom: 8rpx;
	display: block;
}

.header-info .page-subtitle {
	font-size: 28rpx;
	color: #718096;
	display: block;
}

.status-info {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-top: 8rpx;
}

.status-dot {
	width: 16rpx;
	height: 16rpx;
	border-radius: 50%;
	background: #ef4444;
	transition: all 0.3s ease;
}

.status-dot.active {
	background: #10b981;
	box-shadow: 0 0 8rpx rgba(16, 185, 129, 0.4);
}

.status-text {
	font-size: 24rpx;
	color: #9ca3af;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 24rpx;
}

.search-container {
	display: flex;
	align-items: center;
	gap: 12rpx;
	background: #fff;
	border-radius: 20rpx;
	padding: 8rpx;
	box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
	border: 1rpx solid #f1f5f9;
	transition: all 0.3s ease;
	min-width: 400rpx;
}

.search-container:focus-within {
	border-color: #e2e8f0;
	box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.12);
}

.search-box {
	position: relative;
	display: flex;
	align-items: center;
	flex: 1;
	padding: 0 20rpx;
}

.search-icon {
	margin-right: 12rpx;
	font-size: 32rpx;
	color: #64748b;
	transition: color 0.3s ease;
}

.search-icon.iconfont {
	font-size: 28rpx;
}

.search-input {
	flex: 1;
	height: 64rpx;
	font-size: 26rpx;
	color: #1e293b;
	background: transparent;
	border: none;
	outline: none;
}

.search-input::placeholder {
	color: #94a3b8;
}

.btn-primary {
	display: flex;
	align-items: center;
	gap: 8rpx;
	background: #8b9dc3;
	color: #fff;
	border: none;
	border-radius: 16rpx;
	padding: 20rpx 32rpx;
	font-size: 28rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.btn-primary:hover {
	background: #7c8db5;
	transform: translateY(-1rpx);
}

.btn-primary:active {
	transform: translateY(0);
}

.btn-primary.btn-compact {
	padding: 12rpx 20rpx;
	font-size: 24rpx;
	gap: 6rpx;
}

/* 搜索按钮样式 */
.search-btn {
	display: flex;
	align-items: center;
	gap: 6rpx;
	background: #8b9dc3;
	color: #fff;
	border: none;
	border-radius: 12rpx;
	padding: 14rpx 20rpx;
	font-size: 22rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.search-btn:hover:not(:disabled) {
	background: #7c8db5;
	transform: translateY(-1rpx);
}

.search-btn:active:not(:disabled) {
	transform: translateY(0);
}

.search-btn:disabled {
	background: #94a3b8;
	cursor: not-allowed;
	transform: none;
}

.clear-btn {
	display: flex;
	align-items: center;
	gap: 6rpx;
	background: #9ca3af;
	color: #fff;
	border: none;
	border-radius: 12rpx;
	padding: 14rpx 20rpx;
	font-size: 22rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.clear-btn:hover {
	background: #6b7280;
	transform: translateY(-1rpx);
}

.clear-btn:active {
	transform: translateY(0);
}

.btn-icon {
	font-size: 32rpx;
	transition: transform 0.3s ease;
}

.btn-icon.iconfont {
	font-size: 28rpx;
}

.btn-icon.rotating {
	animation: rotate 1s linear infinite;
}

@keyframes rotate {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

/* 统计卡片 */
.stats-cards {
	display: flex;
	gap: 24rpx;
	margin-bottom: 32rpx;
}

.stat-card {
	flex: 1;
	background: #fff;
	border-radius: 20rpx;
	padding: 32rpx;
	text-align: center;
	box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
	border: 2rpx solid #f1f5f9;
	transition: all 0.3s ease;
}

.stat-card:hover {
	transform: translateY(-4rpx);
	box-shadow: 0 8rpx 24rpx rgba(0,0,0,0.1);
}

.stat-number {
	font-size: 56rpx;
	font-weight: 800;
	color: #10b981;
	margin-bottom: 8rpx;
}

.stat-label {
	font-size: 26rpx;
	color: #64748b;
	font-weight: 500;
}

/* 积分表格容器 */
.points-table-container {
	background: #fff;
	border-radius: 20rpx;
	box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
	border: 2rpx solid #f1f5f9;
	overflow: hidden;
}

.table-header {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 24rpx;
	padding: 32rpx;
	border-bottom: 2rpx solid #f1f5f9;
}

.table-title {
	font-size: 36rpx;
	font-weight: 700;
	color: #1a202c;
	flex-shrink: 0;
}

/* 筛选工具栏 */
.filter-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 32rpx;
	flex: 1;
	min-width: 0;
}

.filter-group {
	display: flex;
	align-items: center;
	gap: 16rpx;
	flex-wrap: wrap;
}

.filter-label {
	font-size: 26rpx;
	font-weight: 600;
	color: #64748b;
	display: flex;
	align-items: center;
	gap: 8rpx;
	white-space: nowrap;
}

.filter-label .iconfont {
	font-size: 24rpx;
}

/* 积分范围筛选 */
.filter-range {
	display: flex;
	align-items: center;
	gap: 12rpx;
	flex-wrap: wrap;
}

.range-input {
	width: 140rpx;
	height: 56rpx;
	padding: 0 16rpx;
	border: 2rpx solid #cbd5e1;
	border-radius: 12rpx;
	font-size: 24rpx;
	color: #1e293b;
	background: #fff;
	text-align: center;
	transition: all 0.2s ease;
}

.range-input:focus {
	border-color: #8b9dc3;
	box-shadow: 0 0 0 2rpx rgba(139, 157, 195, 0.15);
	outline: none;
}

.range-input::placeholder {
	color: #94a3b8;
	font-size: 22rpx;
}

.range-separator {
	font-size: 24rpx;
	color: #64748b;
	font-weight: 500;
}

.apply-btn {
	height: 56rpx;
	padding: 0 24rpx;
	background: linear-gradient(135deg, #8b9dc3 0%, #667eea 100%);
	color: #fff;
	border: none;
	border-radius: 12rpx;
	font-size: 24rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.apply-btn:hover {
	background: linear-gradient(135deg, #7c8db5 0%, #5568d3 100%);
	transform: translateY(-1rpx);
	box-shadow: 0 4rpx 12rpx rgba(139, 157, 195, 0.3);
}

.clear-filter-btn {
	width: 56rpx;
	height: 56rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f1f5f9;
	color: #64748b;
	border: 2rpx solid #cbd5e1;
	border-radius: 12rpx;
	font-size: 24rpx;
	transition: all 0.2s ease;
	padding: 0;
}

.clear-filter-btn:hover {
	background: #fee2e2;
	border-color: #fca5a5;
	color: #dc2626;
}

.clear-filter-btn .iconfont {
	font-size: 22rpx;
}

/* 排序按钮 */
.sort-buttons {
	display: flex;
	gap: 12rpx;
	flex-wrap: wrap;
}

.sort-btn {
	height: 56rpx;
	padding: 0 20rpx;
	background: #fff;
	color: #64748b;
	border: 2rpx solid #cbd5e1;
	border-radius: 12rpx;
	font-size: 24rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.sort-btn:hover {
	border-color: #8b9dc3;
	color: #8b9dc3;
	background: #f8fafc;
}

.sort-btn.active {
	background: linear-gradient(135deg, #8b9dc3 0%, #667eea 100%);
	border-color: #8b9dc3;
	color: #fff;
	box-shadow: 0 4rpx 12rpx rgba(139, 157, 195, 0.3);
	transform: translateY(-1rpx);
}

.sort-btn.active:hover {
	background: linear-gradient(135deg, #7c8db5 0%, #5568d3 100%);
	border-color: #7c8db5;
}

.table-actions {
	flex-shrink: 0;
}

.btn-secondary {
	display: flex;
	align-items: center;
	gap: 8rpx;
	background: #f8fafc;
	color: #64748b;
	border: 1rpx solid #e2e8f0;
	border-radius: 12rpx;
	padding: 16rpx 24rpx;
	font-size: 26rpx;
	font-weight: 500;
	text-decoration: none;
	transition: all 0.2s ease;
}

.btn-secondary:hover {
	background: #f1f5f9;
	color: #475569;
	border-color: #cbd5e1;
	transform: translateY(-1rpx);
}

.btn-secondary:active {
	transform: translateY(0);
}

/* 紧凑型按钮 */
.btn-compact {
	padding: 12rpx 20rpx;
	font-size: 24rpx;
	gap: 6rpx;
	border-radius: 10rpx;
}

.btn-compact .btn-icon {
	font-size: 24rpx;
}

/* 紫色按钮变体 */
.btn-purple {
	background: #f3f4f6;
	color: #7c3aed;
	border-color: #e5e7eb;
}

.btn-purple:hover {
	background: #f9fafb;
	color: #6d28d9;
	border-color: #d1d5db;
}

/* 红色按钮变体 */
.btn-red {
	background: #fef2f2;
	color: #dc2626;
	border-color: #fecaca;
}

.btn-red:hover {
	background: #fee2e2;
	color: #b91c1c;
	border-color: #fca5a5;
}

/* 积分表格 */
.points-table {
	width: 100%;
}

.table-row {
	display: grid;
	grid-template-columns: 2fr 1fr 1fr 0.8fr 1.5fr 1fr;
	align-items: center;
	padding: 24rpx 32rpx;
	border-bottom: 2rpx solid #f8fafc;
	transition: all 0.3s ease;
}

.table-row:hover:not(.table-header-row) {
	background: #f8fafc;
}

.table-header-row {
	background: #f8fafc;
	font-weight: 600;
	color: #4a5568;
	font-size: 26rpx;
	border-bottom: 2rpx solid #e2e8f0;
}

.table-cell {
	padding: 0 8rpx;
	display: flex;
	align-items: center;
}

.cell-user {
	display: flex;
	align-items: center;
}

/* 居中对齐的列 */
.cell-points,
.cell-credit,
.cell-level {
	justify-content: center;
}
/* 用户信息 */
.user-info {
	display: flex !important;
	align-items: center;
	gap: 24rpx;
	width: 100%;
	flex-direction: row;
}

.user-avatar {
	width: 80rpx;
	height: 80rpx;
	border-radius: 50%;
	background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	color: #fff;
	font-size: 28rpx;
	flex-shrink: 0;
	border: 2rpx solid #93c5fd;
}

.avatar-text {
	font-size: 28rpx;
}

.user-details {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 80rpx;
}

.user-details .username {
	font-size: 30rpx;
	font-weight: 600;
	color: #1a202c;
	margin-bottom: 4rpx;
}

.user-details .nickname {
	font-size: 24rpx;
	color: #718096;
}

/* 积分信息 */
.points-info, .credit-info {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4rpx;
	text-align: center;
}

.points-value, .credit-value {
	display: block;
	font-size: 32rpx;
	font-weight: 700;
}

.points-value {
	color: #10b981;
}

.credit-value.credit-excellent {
	color: #10b981;
}

.credit-value.credit-good {
	color: #3b82f6;
}

.credit-value.credit-fair {
	color: #f59e0b;
}

.credit-value.credit-poor {
	color: #ef4444;
}

.points-label, .credit-label {
	font-size: 22rpx;
	color: #9ca3af;
}

/* 等级徽章 */
.level-badge {
	padding: 8rpx 16rpx;
	border-radius: 12rpx;
	font-size: 22rpx;
	font-weight: 600;
	text-align: center;
}

.level-diamond {
	background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
	color: #4338ca;
	font-weight: 700;
}

.level-gold {
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	color: #d97706;
	font-weight: 700;
}

.level-silver {
	background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
	color: #475569;
	font-weight: 700;
}

.level-vip {
	background: #fef3c7;
	color: #d97706;
}

.level-high {
	background: #dbeafe;
	color: #2563eb;
}

.level-medium {
	background: #d1fae5;
	color: #059669;
}

.level-new {
	background: #f3f4f6;
	color: #6b7280;
}

/* 变动信息 */
.change-info {
	display: flex;
	flex-direction: column;
	gap: 4rpx;
}

.change-amount {
	font-size: 28rpx;
	font-weight: 600;
}

.change-amount.positive {
	color: #10b981;
}

.change-amount.negative {
	color: #ef4444;
}

.change-reason {
	font-size: 24rpx;
	color: #374151;
}

.change-time {
	font-size: 22rpx;
	color: #9ca3af;
}

.no-change {
	font-size: 24rpx;
	color: #9ca3af;
}

/* 操作按钮 */
.action-buttons {
	display: flex;
	gap: 12rpx;
	justify-content: center;
}

.action-btn {
	width: 64rpx;
	height: 64rpx;
	border-radius: 12rpx;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28rpx;
	transition: all 0.3s ease;
}

.btn-detail {
	background: #eff6ff;
	color: #2563eb;
}

.btn-adjust {
	background: #ecfdf5;
	color: #059669;
}

.btn-history {
	background: #fef3c7;
	color: #d97706;
}

.action-btn:hover {
	transform: scale(1.1);
}

/* 模态框样式 */
.modal-overlay {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0,0,0,0.6);
	backdrop-filter: blur(8rpx);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

.modal-container {
	width: 90%;
	max-width: 800rpx;
	background: #fff;
	border-radius: 28rpx;
	box-shadow: 0 24rpx 48rpx rgba(0, 0, 0, 0.2),
	            0 12rpx 24rpx rgba(0, 0, 0, 0.12),
	            0 0 0 1rpx rgba(0, 0, 0, 0.05);
	animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
	max-height: 90vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.modal-container.large {
	max-width: 1000rpx;
}

.modal-container.debug-modal {
	max-width: 1200rpx;
	width: 95%;
}

.modal-body {
	padding: 40rpx;
	overflow-y: auto;
	flex: 1;
}

@keyframes slideUp {
	0% { 
		opacity: 0;
		transform: translateY(60rpx) scale(0.92);
		filter: blur(4rpx);
	}
	50% {
		opacity: 0.8;
		transform: translateY(-8rpx) scale(1.01);
	}
	100% { 
		opacity: 1;
		transform: translateY(0) scale(1);
		filter: blur(0);
	}
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 44rpx 40rpx;
	background: #fafbfc;
	border-bottom: 1rpx solid #e9ecef;
	position: relative;
	overflow: hidden;
}

.modal-header::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3rpx;
	background: linear-gradient(90deg, #e9ecef 0%, #dee2e6 50%, #e9ecef 100%);
}

.modal-header::after {
	content: '';
	position: absolute;
	top: -100rpx;
	right: -100rpx;
	width: 300rpx;
	height: 300rpx;
	background: radial-gradient(circle, rgba(222, 226, 230, 0.03) 0%, transparent 70%);
	pointer-events: none;
}

.modal-title {
	display: flex;
	align-items: center;
	gap: 20rpx;
	position: relative;
	z-index: 1;
}

.title-icon {
	width: 68rpx;
	height: 68rpx;
	border-radius: 15rpx;
	background: #e9ecef;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 34rpx;
	color: #6c757d;
	box-shadow: 0 2rpx 8rpx rgba(108, 117, 125, 0.08);
}

.title-icon.iconfont {
	font-size: 30rpx;
}

.title-text {
	font-size: 36rpx;
	font-weight: 600;
	color: #495057;
	letter-spacing: 0.3rpx;
}

.modal-close {
	width: 68rpx;
	height: 68rpx;
	border-radius: 15rpx;
	background: #f8f9fa;
	backdrop-filter: blur(10rpx);
	border: 1rpx solid #e9ecef;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 30rpx;
	color: #6c757d;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	z-index: 1;
}

.modal-close:hover {
	background: #fff;
	border-color: #dee2e6;
	color: #495057;
	transform: scale(1.05);
	box-shadow: 0 4rpx 12rpx rgba(108, 117, 125, 0.15);
}

/* 用户信息卡片 */
.user-info-card {
	display: flex;
	align-items: center;
	gap: 24rpx;
	padding: 24rpx;
	background: #f8fafc;
	border-radius: 16rpx;
	margin-bottom: 32rpx;
}

.user-info-card.enhanced {
	background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
	color: #495057;
	position: relative;
	overflow: hidden;
	padding: 32rpx;
	border: 1rpx solid #dee2e6;
}

.user-info-card.enhanced::before {
	content: '';
	position: absolute;
	top: -50%;
	right: -50%;
	width: 200%;
	height: 200%;
	background: radial-gradient(circle, rgba(222, 226, 230, 0.3) 0%, transparent 70%);
	pointer-events: none;
}

.user-avatar-wrapper {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12rpx;
}

.user-level-badge {
	padding: 6rpx 16rpx;
	border-radius: 20rpx;
	font-size: 22rpx;
	font-weight: 600;
	background: rgba(255, 255, 255, 0.8);
	backdrop-filter: blur(10rpx);
	border: 1rpx solid #ced4da;
	color: #6c757d;
}

.username-row {
	display: flex;
	align-items: center;
	gap: 16rpx;
	margin-bottom: 16rpx;
}

.user-id {
	font-size: 24rpx;
	background: rgba(255, 255, 255, 0.8);
	padding: 4rpx 12rpx;
	border-radius: 12rpx;
	color: #6c757d;
	border: 1rpx solid #ced4da;
}

.stats-row {
	display: flex;
	align-items: center;
	gap: 24rpx;
}

.stat-item {
	display: flex;
	align-items: center;
	gap: 8rpx;
}

.stat-icon {
	font-size: 28rpx;
}

.stat-value {
	font-size: 32rpx;
	font-weight: 700;
}

.stat-label {
	font-size: 24rpx;
	opacity: 0.9;
}

.stat-divider {
	width: 2rpx;
	height: 40rpx;
	background: #ced4da;
}

.user-info-card .user-details {
	flex: 1;
}

.user-info-card .username {
	font-size: 32rpx;
	font-weight: 600;
	color: #343a40;
	margin-bottom: 8rpx;
}

.current-stats {
	font-size: 26rpx;
	color: #6b7280;
}

/* 调整表单 */
.adjust-form {
	background: #fff;
}

.adjust-form.enhanced {
	background: #fff;
	border-radius: 16rpx;
	overflow: hidden;
}

.form-tabs, .detail-tabs {
	display: flex;
	background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
	border-radius: 16rpx;
	padding: 8rpx;
	margin-bottom: 32rpx;
	border: 1rpx solid #e5e7eb;
	box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.03);
}

.form-tabs.modern {
	background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
	border-radius: 16rpx;
	padding: 10rpx;
	border: 1rpx solid #e5e7eb;
	margin-bottom: 32rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

.tab-btn {
	flex: 1;
	padding: 20rpx 24rpx;
	border: none;
	background: transparent;
	color: #64748b;
	font-size: 28rpx;
	font-weight: 500;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	border-radius: 12rpx;
	position: relative;
}

.tab-btn.modern {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12rpx;
	padding: 18rpx 28rpx;
	border-radius: 12rpx;
	background: transparent;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
}

.tab-btn.active {
	background: #fff;
	color: #8b9dc3;
	font-weight: 700;
	box-shadow: 0 4rpx 12rpx rgba(139, 157, 195, 0.15), 
	            0 2rpx 4rpx rgba(0, 0, 0, 0.08);
	transform: translateY(-2rpx);
}

.tab-btn.active::before {
	content: '';
	position: absolute;
	bottom: 0;
	left: 20%;
	right: 20%;
	height: 4rpx;
	background: linear-gradient(90deg, transparent, #8b9dc3, transparent);
	border-radius: 2rpx;
}

.tab-btn.modern.active {
	background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
	color: #8b9dc3;
	box-shadow: 0 4rpx 16rpx rgba(139, 157, 195, 0.2),
	            0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	transform: translateY(-2rpx);
}

.tab-icon {
	font-size: 32rpx;
}

.tab-text {
	font-size: 28rpx;
	font-weight: 600;
}

.form-content {
	display: flex;
	flex-direction: column;
	gap: 32rpx;
}

.form-content.enhanced {
	padding: 32rpx;
	gap: 40rpx;
}

.form-group {
	display: flex;
	flex-direction: column;
	gap: 16rpx;
	width: 100%;
}

.form-label {
	font-size: 28rpx;
	font-weight: 600;
	color: #374151;
	display: flex;
	align-items: center;
	gap: 12rpx;
}

.label-icon {
	font-size: 32rpx;
}

/* 操作按钮组 */
.action-buttons {
	display: flex;
	gap: 16rpx;
}

.action-btn {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12rpx;
	padding: 20rpx 32rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 12rpx;
	background: #fff;
	color: #6b7280;
	font-size: 28rpx;
	transition: all 0.3s ease;
}

.action-btn.active {
	border-color: #10b981;
	background: #ecfdf5;
	color: #10b981;
	transform: translateY(-2rpx);
	box-shadow: 0 8rpx 16rpx rgba(16, 185, 129, 0.2);
}

.action-icon {
	font-size: 32rpx;
}

.action-text {
	font-weight: 600;
}

/* 数量输入增强 */
.amount-input-wrapper {
	display: flex;
	flex-direction: column;
	gap: 16rpx;
	width: 100%;
}

.form-input.enhanced {
	width: 100%;
	padding: 24rpx 32rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 12rpx;
	font-size: 32rpx;
	background: #fff;
	transition: all 0.3s ease;
	text-align: center;
	min-height: 80rpx;
	box-sizing: border-box;
}

.form-input.enhanced:focus {
	border-color: #10b981;
	box-shadow: 0 0 0 4rpx rgba(16, 185, 129, 0.1);
	outline: none;
}

.quick-amounts {
	display: flex;
	gap: 12rpx;
	justify-content: center;
	flex-wrap: wrap;
	width: 100%;
}

.quick-btn {
	flex: 1;
	max-width: 120rpx;
	padding: 16rpx 20rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 12rpx;
	background: #f9fafb;
	color: #6b7280;
	font-size: 26rpx;
	font-weight: 500;
	text-align: center;
	transition: all 0.3s ease;
}

.quick-btn:hover {
	border-color: #10b981;
	color: #10b981;
	background: #ecfdf5;
}

/* 自定义原因输入框 */
.custom-reason-input {
	text-align: left !important;
	padding: 20rpx 24rpx !important;
	min-height: 60rpx !important;
}

.radio-group {
	display: flex;
	gap: 32rpx;
}

.radio-item {
	display: flex;
	align-items: center;
	gap: 8rpx;
	cursor: pointer;
}

.reason-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 12rpx;
	margin-bottom: 16rpx;
}

.reason-tag {
	padding: 12rpx 20rpx;
	border: 2rpx solid #e5e7eb;
	background: #fff;
	color: #6b7280;
	border-radius: 12rpx;
	font-size: 26rpx;
	transition: all 0.3s ease;
}

.reason-tag.active {
	border-color: #10b981;
	background: #ecfdf5;
	color: #059669;
}

/* 增强样式 */
.reason-tags.enhanced {
	gap: 16rpx;
}

.reason-tag.modern {
	display: flex;
	align-items: center;
	gap: 8rpx;
	padding: 16rpx 24rpx;
	border-radius: 20rpx;
	transition: all 0.3s ease;
}

.reason-tag.modern.active {
	transform: translateY(-2rpx);
	box-shadow: 0 8rpx 16rpx rgba(16, 185, 129, 0.2);
}

.reason-icon {
	font-size: 28rpx;
}

.reason-icon.iconfont {
	font-size: 24rpx;
}

.reason-text {
	font-size: 26rpx;
	font-weight: 500;
}

/* 文本域增强 */
.form-textarea.enhanced {
	width: 100%;
	padding: 20rpx 24rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 12rpx;
	font-size: 28rpx;
	background: #fff;
	min-height: 120rpx;
	resize: vertical;
	transition: all 0.3s ease;
	box-sizing: border-box;
}

.form-textarea.enhanced:focus {
	border-color: #10b981;
	box-shadow: 0 0 0 4rpx rgba(16, 185, 129, 0.1);
	outline: none;
}

/* 预览部分 */
.preview-section {
	background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
	border: 2rpx solid #0ea5e9;
	border-radius: 16rpx;
	padding: 32rpx;
	margin-top: 24rpx;
}

.preview-title {
	font-size: 32rpx;
	font-weight: 700;
	color: #0ea5e9;
	margin-bottom: 24rpx;
	display: flex;
	align-items: center;
	gap: 12rpx;
}


.preview-content {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 32rpx;
}

.preview-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8rpx;
}

.preview-label {
	font-size: 24rpx;
	color: #64748b;
}

.preview-value {
	font-size: 40rpx;
	font-weight: 700;
	padding: 12rpx 24rpx;
	border-radius: 12rpx;
	background: rgba(255, 255, 255, 0.8);
}

.preview-value.current {
	color: #64748b;
	border: 2rpx solid #e2e8f0;
}

.preview-value.increase {
	color: #059669;
	background: #ecfdf5;
	border: 2rpx solid #10b981;
}

.preview-value.decrease {
	color: #dc2626;
	background: #fef2f2;
	border: 2rpx solid #ef4444;
}

.preview-arrow {
	font-size: 48rpx;
	color: #0ea5e9;
	font-weight: 700;
}

.form-input {
	width: 100%;
	padding: 24rpx 20rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 16rpx;
	font-size: 28rpx;
	color: #374151;
	background: #fff;
	transition: all 0.3s ease;
}

.form-input:focus {
	border-color: #10b981;
	box-shadow: 0 0 0 6rpx rgba(16, 185, 129, 0.1);
	outline: none;
}

.form-textarea {
	width: 100%;
	min-height: 120rpx;
	padding: 24rpx 20rpx;
	border: 2rpx solid #e5e7eb;
	border-radius: 16rpx;
	font-size: 28rpx;
	color: #374151;
	background: #fff;
	resize: vertical;
	transition: all 0.3s ease;
}

.form-textarea:focus {
	border-color: #10b981;
	box-shadow: 0 0 0 6rpx rgba(16, 185, 129, 0.1);
	outline: none;
}

.modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: 20rpx;
	padding: 32rpx 40rpx;
	background: #fafbfc;
	border-top: 1rpx solid #e9ecef;
	position: relative;
}

.modal-footer::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 1rpx;
	background: linear-gradient(90deg, transparent, #dee2e6 20%, #dee2e6 80%, transparent);
}

.btn-cancel {
	padding: 24rpx 48rpx;
	border: 2rpx solid #e9ecef;
	background: #fff;
	color: #6c757d;
	border-radius: 14rpx;
	font-size: 28rpx;
	font-weight: 500;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	min-width: 160rpx;
}

.btn-cancel:hover {
	background: #f8f9fa;
	border-color: #dee2e6;
	color: #495057;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
}

.btn-submit {
	padding: 24rpx 48rpx;
	background: #495057;
	color: #fff;
	border: none;
	border-radius: 14rpx;
	font-size: 28rpx;
	font-weight: 500;
	box-shadow: 0 4rpx 12rpx rgba(73, 80, 87, 0.15);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	overflow: hidden;
	min-width: 160rpx;
}

.btn-submit::before {
	content: '';
	position: absolute;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
	transition: left 0.5s ease;
}

.btn-submit:hover:not(:disabled)::before {
	left: 100%;
}

.btn-submit:hover:not(:disabled) {
	background: #343a40;
	transform: translateY(-2rpx);
	box-shadow: 0 8rpx 20rpx rgba(73, 80, 87, 0.2);
}

.btn-submit:active:not(:disabled) {
	transform: translateY(0);
}

.btn-submit:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: 0 2rpx 8rpx rgba(73, 80, 87, 0.1);
}

/* 详情内容 */
.detail-content {
	min-height: 400rpx;
}

.overview-content {
	padding: 24rpx 0;
}

.stats-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 32rpx;
}

.stat-item {
	text-align: center;
	padding: 32rpx;
	background: #f8fafc;
	border-radius: 16rpx;
}

.stat-item .stat-value {
	font-size: 48rpx;
	font-weight: 700;
	color: #10b981;
	display: block;
	margin-bottom: 8rpx;
}

.stat-item .stat-label {
	font-size: 26rpx;
	color: #6b7280;
}

.history-content {
	padding: 24rpx 0;
}

.history-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16rpx 24rpx;
	margin-bottom: 16rpx;
	background: #f8fafc;
	border-radius: 12rpx;
	border: 1rpx solid #e2e8f0;
}

.history-title {
	font-size: 28rpx;
	font-weight: 600;
	color: #1a202c;
}

.history-sort-tip {
	font-size: 22rpx;
	color: #64748b;
	background: #e2e8f0;
	padding: 4rpx 12rpx;
	border-radius: 12rpx;
}

.history-list {
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}

.history-item {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	padding: 24rpx;
	background: #f8fafc;
	border-radius: 16rpx;
	border-left: 6rpx solid #10b981;
}

.history-info {
	flex: 1;
}

.history-amount {
	font-size: 32rpx;
	font-weight: 700;
	margin-bottom: 8rpx;
	display: block;
}

.history-amount.positive {
	color: #10b981;
}

.history-amount.negative {
	color: #ef4444;
}

.history-reason {
	font-size: 28rpx;
	color: #374151;
	margin-bottom: 4rpx;
	display: block;
}

.history-note {
	font-size: 24rpx;
	color: #6b7280;
	display: block;
}

.history-meta {
	text-align: right;
	flex-shrink: 0;
	margin-left: 24rpx;
}

.history-time {
	font-size: 24rpx;
	color: #9ca3af;
	display: block;
	margin-bottom: 4rpx;
}

.history-operator {
	font-size: 22rpx;
	color: #6b7280;
	display: block;
}

/* 历史记录筛选器 */
.history-filter {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24rpx;
	padding: 24rpx;
	background: #f8f9fa;
	border-radius: 12rpx;
	margin-bottom: 32rpx;
	border: 1rpx solid #e9ecef;
	flex-wrap: wrap;
}

.history-filter .filter-label {
	display: flex;
	align-items: center;
	gap: 8rpx;
	font-size: 26rpx;
	font-weight: 600;
	color: #495057;
	white-space: nowrap;
}

.history-filter .filter-label .iconfont {
	font-size: 24rpx;
	color: #6c757d;
}

.history-filter .filter-buttons {
	display: flex;
	gap: 12rpx;
	flex-wrap: wrap;
}

.history-filter .filter-btn {
	padding: 10rpx 24rpx;
	border: 2rpx solid #dee2e6;
	background: #fff;
	color: #6c757d;
	border-radius: 20rpx;
	font-size: 24rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	gap: 6rpx;
}

.history-filter .filter-btn:hover {
	border-color: #adb5bd;
	color: #495057;
}

.history-filter .filter-btn.active {
	background: #495057;
	border-color: #495057;
	color: #fff;
	box-shadow: 0 2rpx 8rpx rgba(73, 80, 87, 0.2);
}

.history-filter .filter-btn.gain.active {
	background: #10b981;
	border-color: #10b981;
	box-shadow: 0 2rpx 8rpx rgba(16, 185, 129, 0.3);
}

.history-filter .filter-btn.consume.active {
	background: #ef4444;
	border-color: #ef4444;
	box-shadow: 0 2rpx 8rpx rgba(239, 68, 68, 0.3);
}

.history-filter .filter-btn .iconfont {
	font-size: 20rpx;
}

/* 时间线容器 */
.timeline-container {
	padding: 16rpx 0;
}

.timeline-item {
	display: flex;
	gap: 24rpx;
	margin-bottom: 32rpx;
	position: relative;
}

.timeline-item:last-child {
	margin-bottom: 0;
}

/* 时间线节点 */
.timeline-node {
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
	position: relative;
}

.node-dot {
	width: 24rpx;
	height: 24rpx;
	border-radius: 50%;
	border: 4rpx solid #fff;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15);
	transition: all 0.3s ease;
}

.node-gain .node-dot {
	background: #10b981;
}

.node-consume .node-dot {
	background: #ef4444;
}

.node-line {
	width: 3rpx;
	flex: 1;
	min-height: 60rpx;
	background: linear-gradient(180deg, #dee2e6 0%, #f8f9fa 100%);
	margin-top: 8rpx;
}

/* 时间线卡片 */
.timeline-card {
	flex: 1;
	padding: 24rpx;
	background: #fff;
	border-radius: 16rpx;
	border: 2rpx solid #e9ecef;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
}

.timeline-card::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 4rpx;
	transition: all 0.3s ease;
}

.timeline-card.card-gain::before {
	background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.timeline-card.card-consume::before {
	background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.timeline-card:hover {
	border-color: #dee2e6;
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
	transform: translateX(4rpx);
}

/* 卡片头部 */
.card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16rpx;
	padding-bottom: 16rpx;
	border-bottom: 1rpx solid #f1f3f5;
}

.card-amount {
	font-size: 36rpx;
	font-weight: 700;
	display: flex;
	align-items: baseline;
	gap: 8rpx;
}

.card-amount.positive {
	color: #10b981;
}

.card-amount.negative {
	color: #ef4444;
}

.amount-unit {
	font-size: 22rpx;
	font-weight: 500;
	color: #6c757d;
}

.card-time {
	font-size: 22rpx;
	color: #6c757d;
	background: #f8f9fa;
	padding: 6rpx 12rpx;
	border-radius: 12rpx;
}

/* 卡片主体 */
.card-body {
	margin-bottom: 12rpx;
}

.card-type {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-bottom: 12rpx;
}

.type-icon {
	font-size: 28rpx;
	color: #6c757d;
	width: 32rpx;
	height: 32rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f8f9fa;
	border-radius: 8rpx;
	flex-shrink: 0;
}

.type-text {
	font-size: 28rpx;
	font-weight: 600;
	color: #343a40;
}

.card-note {
	font-size: 24rpx;
	color: #6c757d;
	line-height: 1.6;
	padding: 12rpx 16rpx;
	background: #f8f9fa;
	border-radius: 8rpx;
	border-left: 3rpx solid #dee2e6;
}

/* 卡片底部 */
.card-footer {
	display: flex;
	align-items: center;
	gap: 8rpx;
	padding-top: 12rpx;
	border-top: 1rpx solid #f1f3f5;
	font-size: 22rpx;
	color: #6c757d;
}

.card-footer .iconfont {
	font-size: 20rpx;
}

.operator-text {
	font-size: 22rpx;
}

/* 空状态 */
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 80rpx 32rpx;
	color: #adb5bd;
}

.empty-state .iconfont {
	font-size: 120rpx;
	margin-bottom: 24rpx;
	opacity: 0.5;
}

.empty-text {
	font-size: 28rpx;
	color: #adb5bd;
}

/* 响应式设计 */
@media (max-width: 900px) {
	.page {
		padding: 24rpx;
	}
	
	.page-header {
		flex-direction: column;
		align-items: stretch;
		gap: 24rpx;
	}
	
	.header-actions {
		flex-direction: column;
		align-items: stretch;
		gap: 20rpx;
	}
	
	.search-container {
		min-width: auto;
		width: 100%;
		flex-wrap: wrap;
		padding: 12rpx;
	}
	
	.search-box {
		min-width: 200rpx;
	}
	
	.search-btn, .clear-btn {
		padding: 18rpx 24rpx;
		font-size: 24rpx;
	}
	
	.btn-primary {
		justify-content: center;
		width: 100%;
	}
	
	.stats-cards {
		grid-template-columns: repeat(2, 1fr);
	}
	
	.table-header {
		flex-direction: column;
		align-items: stretch;
		gap: 20rpx;
	}
	
	.filter-toolbar {
		flex-direction: column;
		align-items: stretch;
		gap: 20rpx;
		width: 100%;
	}
	
	.filter-group {
		flex-direction: column;
		align-items: stretch;
		gap: 12rpx;
		width: 100%;
	}
	
	.filter-range,
	.sort-buttons {
		width: 100%;
		justify-content: stretch;
	}
	
	.range-input {
		flex: 1;
		min-width: 100rpx;
	}
	
	.sort-btn {
		flex: 1;
		justify-content: center;
	}
	
	.table-actions {
		width: 100%;
	}
	
	.btn-secondary {
		width: 100%;
		justify-content: center;
	}
	
	.table-row {
		grid-template-columns: 1fr;
		gap: 16rpx;
		padding: 24rpx 16rpx;
	}
	
	.table-cell {
		padding: 8rpx 0;
	}
	
	.user-info {
		display: flex !important;
		flex-direction: row !important;
		align-items: center;
		gap: 16rpx;
	}
	
	.stats-grid {
		grid-template-columns: 1fr;
	}
	
	/* 时间线响应式 */
	.history-filter {
		flex-direction: column;
		align-items: stretch;
	}
	
	.history-filter .filter-buttons {
		width: 100%;
		justify-content: stretch;
	}
	
	.history-filter .filter-btn {
		flex: 1;
		justify-content: center;
	}
	
	.timeline-item {
		gap: 16rpx;
	}
	
	.timeline-card {
		padding: 20rpx;
	}
	
	.card-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 12rpx;
	}
	
	.card-amount {
		font-size: 32rpx;
	}
}

@media (max-width: 600px) {
	.search-container {
		flex-direction: column;
		gap: 16rpx;
		padding: 16rpx;
	}
	
	.search-box {
		width: 100%;
	}
	
	.search-btn, .clear-btn {
		width: 100%;
		justify-content: center;
	}
	
	/* 更小屏幕的时间线调整 */
	.timeline-item {
		gap: 12rpx;
	}
	
	.node-dot {
		width: 20rpx;
		height: 20rpx;
	}
	
	.timeline-card {
		padding: 16rpx;
	}
	
	.card-amount {
		font-size: 28rpx;
	}
	
	.type-text {
		font-size: 26rpx;
	}
	
	.card-note {
		font-size: 22rpx;
	}
}

/* 调试弹窗样式 */
.debug-body {
	padding: 32rpx;
	max-height: 70vh;
	overflow-y: auto;
}

.debug-section {
	margin-bottom: 40rpx;
}

.section-title {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-bottom: 24rpx;
	padding-bottom: 12rpx;
	border-bottom: 2rpx solid #f1f5f9;
}

.section-icon {
	font-size: 32rpx;
}

.section-text {
	font-size: 32rpx;
	font-weight: 700;
	color: #1a202c;
}

/* 配置标签页 */
.config-tabs {
	display: flex;
	gap: 8rpx;
	margin-bottom: 32rpx;
	padding: 8rpx;
	background: #f8fafc;
	border-radius: 12rpx;
	overflow-x: auto;
}

.config-tab {
	padding: 12rpx 20rpx;
	border: none;
	background: transparent;
	color: #64748b;
	font-size: 24rpx;
	font-weight: 500;
	border-radius: 8rpx;
	transition: all 0.2s ease;
	white-space: nowrap;
	min-width: 120rpx;
}

.config-tab.active {
	background: #fff;
	color: #8b9dc3;
	box-shadow: 0 2rpx 8rpx rgba(139, 157, 195, 0.2);
}

.config-tab:hover:not(.active) {
	background: #f1f5f9;
	color: #475569;
}

/* 配置面板 */
.config-panel {
	background: #fff;
	border-radius: 12rpx;
	padding: 24rpx;
	border: 1rpx solid #f1f5f9;
}

.config-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300rpx, 1fr));
	gap: 24rpx;
}

.config-item {
	display: flex;
	align-items: center;
	gap: 12rpx;
	padding: 16rpx;
	background: #f8fafc;
	border-radius: 8rpx;
	border: 1rpx solid #e2e8f0;
}

.config-label {
	font-size: 26rpx;
	color: #374151;
	font-weight: 500;
	min-width: 120rpx;
	text-align: right;
}

.config-input {
	flex: 1;
	padding: 8rpx 12rpx;
	border: 1rpx solid #d1d5db;
	border-radius: 6rpx;
	font-size: 24rpx;
	background: #fff;
	text-align: center;
	max-width: 100rpx;
}

.config-input:focus {
	border-color: #8b9dc3;
	outline: none;
	box-shadow: 0 0 0 2rpx rgba(139, 157, 195, 0.1);
}

.config-unit {
	font-size: 22rpx;
	color: #6b7280;
	min-width: 40rpx;
}

.config-note {
	margin-top: 24rpx;
	padding: 16rpx 20rpx;
	background: #f0f9ff;
	border: 1rpx solid #bae6fd;
	border-radius: 8rpx;
}

.note-text {
	font-size: 24rpx;
	color: #0369a1;
	line-height: 1.5;
}

/* 测试控制区域 */
.test-controls {
	margin-bottom: 24rpx;
}

.test-actions {
	display: flex;
	gap: 16rpx;
	flex-wrap: wrap;
}

.test-btn {
	display: flex;
	align-items: center;
	gap: 8rpx;
	padding: 12rpx 20rpx;
	border: none;
	border-radius: 8rpx;
	font-size: 24rpx;
	font-weight: 500;
	transition: all 0.2s ease;
	background: #8b9dc3;
	color: #fff;
}

.test-btn:hover {
	background: #7c8db5;
	transform: translateY(-1rpx);
}

.test-btn.secondary {
	background: #f8fafc;
	color: #64748b;
	border: 1rpx solid #e2e8f0;
}

.test-btn.secondary:hover {
	background: #f1f5f9;
	color: #475569;
}

/* 测试结果 */
.test-results {
	background: #fff;
	border-radius: 12rpx;
	border: 1rpx solid #f1f5f9;
	overflow: hidden;
}

.results-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx 24rpx;
	background: #f8fafc;
	border-bottom: 1rpx solid #f1f5f9;
}

.results-title {
	font-size: 28rpx;
	font-weight: 600;
	color: #1a202c;
}

.results-count {
	font-size: 22rpx;
	color: #6b7280;
	background: #e5e7eb;
	padding: 4rpx 12rpx;
	border-radius: 12rpx;
}

.results-list {
	max-height: 400rpx;
	overflow-y: auto;
}

.result-item {
	display: flex;
	align-items: center;
	gap: 24rpx;
	padding: 20rpx 24rpx;
	border-bottom: 1rpx solid #f8fafc;
	transition: background 0.2s ease;
}

.result-item:hover {
	background: #f8fafc;
}

.result-item:last-child {
	border-bottom: none;
}

.result-user {
	min-width: 160rpx;
}

.user-name {
	font-size: 26rpx;
	font-weight: 600;
	color: #1a202c;
	display: block;
	margin-bottom: 4rpx;
}

.user-info {
	font-size: 20rpx;
	color: #6b7280;
	display: block;
}

.result-changes {
	display: flex;
	gap: 12rpx;
	flex-wrap: wrap;
	flex: 1;
}

.change-item {
	display: flex;
	align-items: center;
	gap: 6rpx;
	padding: 6rpx 12rpx;
	background: #f3f4f6;
	border-radius: 16rpx;
	font-size: 20rpx;
}

.change-action {
	color: #374151;
}

.change-value {
	font-weight: 600;
}

.change-value.positive {
	color: #059669;
}

.change-value.negative {
	color: #dc2626;
}

.result-final {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 4rpx;
	min-width: 120rpx;
}

.final-points {
	font-size: 24rpx;
	font-weight: 600;
	color: #1a202c;
}

.final-level {
	font-size: 20rpx;
	color: #6b7280;
	padding: 2rpx 8rpx;
	background: #e5e7eb;
	border-radius: 8rpx;
}

/* 响应式调试弹窗 */
@media (max-width: 900px) {
	.debug-body {
		padding: 24rpx;
	}
	
	.config-grid {
		grid-template-columns: 1fr;
	}
	
	.config-item {
		flex-direction: column;
		align-items: stretch;
		gap: 8rpx;
	}
	
	.config-label {
		text-align: left;
		min-width: auto;
	}
	
	.config-input {
		max-width: none;
	}
	
	.result-item {
		flex-direction: column;
		align-items: stretch;
		gap: 12rpx;
	}
	
	.result-final {
		align-items: flex-start;
	}
	
	.test-actions {
		flex-direction: column;
	}
	
	.test-btn {
		justify-content: center;
	}
}

/* 积分规则弹窗样式 */
.rules-modal {
	max-width: 900rpx;
	width: 90%;
}

.rules-body {
	padding: 32rpx;
	max-height: 70vh;
	overflow-y: auto;
}

.rules-section {
	margin-bottom: 40rpx;
}

.rules-section:last-child {
	margin-bottom: 0;
}

/* 规则列表 */
.rules-list {
	display: flex;
	flex-direction: column;
	gap: 20rpx;
}

.rule-item {
	background: #f8fafc;
	border-radius: 12rpx;
	padding: 24rpx;
	border: 1rpx solid #e9ecef;
	transition: all 0.3s ease;
}

.rule-item:hover {
	background: #fff;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
	transform: translateY(-2rpx);
}

.rule-header {
	display: flex;
	align-items: center;
	gap: 12rpx;
	margin-bottom: 16rpx;
	padding-bottom: 12rpx;
	border-bottom: 2rpx solid #e9ecef;
}

.rule-icon {
	font-size: 28rpx;
	color: #495057;
}

.rule-name {
	font-size: 30rpx;
	font-weight: 600;
	color: #343a40;
}

.rule-details {
	display: flex;
	flex-direction: column;
	gap: 12rpx;
}

.detail-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8rpx 12rpx;
	background: #fff;
	border-radius: 8rpx;
}

.detail-label {
	font-size: 26rpx;
	color: #6c757d;
}

.detail-value {
	font-size: 28rpx;
	font-weight: 600;
	color: #10b981;
}

/* 等级列表 */
.levels-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180rpx, 1fr));
	gap: 16rpx;
}

.level-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12rpx;
	padding: 20rpx;
	background: #f8fafc;
	border-radius: 12rpx;
	border: 2rpx solid #e9ecef;
	transition: all 0.3s ease;
}

.level-item:hover {
	background: #fff;
	transform: translateY(-4rpx);
	box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}

.level-requirement {
	font-size: 24rpx;
	color: #6c757d;
	font-weight: 500;
}

/* 信息列表 */
.info-list {
	display: flex;
	flex-direction: column;
	gap: 16rpx;
}

.info-item {
	display: flex;
	align-items: center;
	gap: 12rpx;
	padding: 16rpx 20rpx;
	background: #f8fafc;
	border-radius: 12rpx;
	border-left: 4rpx solid #8b9dc3;
}

.info-icon {
	font-size: 32rpx;
	flex-shrink: 0;
}

.info-text {
	font-size: 26rpx;
	color: #495057;
	line-height: 1.6;
}

/* 响应式 */
@media (max-width: 900px) {
	.rules-modal {
		width: 95%;
		max-width: 100%;
	}
	
	.rules-body {
		padding: 24rpx;
	}
	
	.levels-list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 600px) {
	.rule-details {
		gap: 8rpx;
	}
	
	.detail-row {
		flex-direction: column;
		align-items: flex-start;
		gap: 4rpx;
	}
	
	.levels-list {
		grid-template-columns: 1fr;
	}
}
</style>

